doc/book/en/tutorials/base/create-cube.rst
branchstable
changeset 5432 ee246e1813c6
parent 5388 9167751463d4
child 6152 6824f8b61098
equal deleted inserted replaced
5429:5ca1f8fe8a42 5432:ee246e1813c6
    28 
    28 
    29 4. :ref:`DefineViews`
    29 4. :ref:`DefineViews`
    30 
    30 
    31 Customize the views of your data: how and which part of your data are showed.
    31 Customize the views of your data: how and which part of your data are showed.
    32 
    32 
    33 Note: views don't concern the look'n'feel or design of the site. For that, you should use CSS instead, and default CSS or your new cube are located in 'blog/data/'.
    33 .. note:: views do not define the look'n'feel and the design of your application. For that, you will use CSS and the files located 'blog/data/'.
    34 
    34 
    35 
    35 
    36 5. :ref:`DefineEntities`
    36 5. :ref:`DefineEntities`
    37 
    37 
    38 Define your own entities to add useful functions when you manipulate your data, especially when you write view.
    38 Define your own entities to add useful functions when you manipulate your data, especially when you write view.
   394 
   394 
   395 While developping your cube, you may want to update your data model. Let's say you
   395 While developping your cube, you may want to update your data model. Let's say you
   396 want to add a ``category`` attribute in the ``Blog`` data type. This is called a migration.
   396 want to add a ``category`` attribute in the ``Blog`` data type. This is called a migration.
   397 
   397 
   398 The required steps are:
   398 The required steps are:
       
   399 
   399 1. modify the file ``schema.py``. The ``Blog`` class looks now like this:
   400 1. modify the file ``schema.py``. The ``Blog`` class looks now like this:
   400 
   401 
   401 .. sourcecode:: python
   402 .. sourcecode:: python
   402 
   403 
   403  class Blog(EntityType):
   404  class Blog(EntityType):
   404    title = String(maxsize=50, required=True)
   405    title = String(maxsize=50, required=True)
   405    description = String()
   406    description = String()
   406    category = String(required=True, vocabulary=(_('Professional'), _('Personal')), default='Personal')
   407    category = String(required=True, vocabulary=(_('Professional'), _('Personal')), default='Personal')
   407 
   408 
   408 2. stop your ``blogdemo`` instance
   409 2. stop your ``blogdemo`` instance:
       
   410 
       
   411 .. sourcecode:: bash
       
   412 
       
   413   cubicweb-ctl stop blogdemo
   409 
   414 
   410 3. start the cubicweb shell for your instance by running the following command:
   415 3. start the cubicweb shell for your instance by running the following command:
   411 
   416 
   412 .. sourcecode:: bash
   417 .. sourcecode:: bash
   413 
   418 
   414   cubicweb-ctl shell blogdemo
   419   cubicweb-ctl shell blogdemo
   415 
   420 
   416 4. in the shell, execute:
   421 4. at the cubicweb shell prompt, execute:
   417 
   422 
   418 .. sourcecode:: python
   423 .. sourcecode:: python
   419 
   424 
   420  add_attribute('Blog', 'category')
   425  add_attribute('Blog', 'category')
   421 
   426 
   422 5. you can restart your instance, modify a blog entity and check that the new attribute
   427 5. restart your instance:
       
   428    
       
   429 .. sourcecode:: bash
       
   430 
       
   431   cubicweb-ctl start blogdemo
       
   432 
       
   433 6. modify a blog entity and check that the new attribute
   423 ``category`` has been added.
   434 ``category`` has been added.
   424 
   435 
   425 Of course, you may also want to add relations, entity types, ... See :ref:`migration`
   436 Of course, you may also want to add relations, entity types, etc. See :ref:`migration`
   426 for a list of all available migration commands.
   437 for a list of all available migration commands.
   427 
   438