doc/book/en/tutorials/base/components.rst
brancholdstable
changeset 7074 e4580e5f0703
parent 6749 48f468f33704
parent 7073 4ce9e536dd66
child 7078 bad26a22fe29
child 7083 b8e35cde46e9
equal deleted inserted replaced
6749:48f468f33704 7074:e4580e5f0703
     1 .. -*- coding: utf-8 -*-
       
     2 
       
     3 .. _cubes:
       
     4 
       
     5 Cubes
       
     6 -----
       
     7 
       
     8 Standard library
       
     9 ~~~~~~~~~~~~~~~~
       
    10 
       
    11 A library of standard cubes are available from `CubicWeb Forge`_
       
    12 Cubes provide entities and views.
       
    13 
       
    14 The available application entities in standard cubes are:
       
    15 
       
    16 * addressbook: PhoneNumber and PostalAddress
       
    17 
       
    18 * basket: Basket (like a shopping cart)
       
    19 
       
    20 * blog: Blog (a *very* basic blog)
       
    21 
       
    22 * classfolder: Folder (to organize things but grouping them in folders)
       
    23 
       
    24 * classtags: Tag (to tag anything)
       
    25 
       
    26 * comment: Comment (to attach comment threads to entities)
       
    27 
       
    28 * file: File (to allow users to upload and store binary or text files)
       
    29 
       
    30 * link: Link (to collect links to web resources)
       
    31 
       
    32 * mailinglist: MailingList (to reference a mailing-list and the URLs
       
    33   for its archives and its admin interface)
       
    34 
       
    35 * person: Person (easily mixed with addressbook)
       
    36 
       
    37 * task: Task (something to be done between start and stop date)
       
    38 
       
    39 * zone: Zone (to define places within larger places, for example a
       
    40   city in a state in a country)
       
    41 
       
    42 .. _`CubicWeb Forge`: http://www.cubicweb.org/project/
       
    43 
       
    44 Adding comments to BlogDemo
       
    45 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    46 
       
    47 To import a cube in your instance just change the line in the
       
    48 ``__pkginfo__.py`` file and verify that the cube you are planning
       
    49 to use is listed by the command ``cubicweb-ctl list``.
       
    50 For example::
       
    51 
       
    52     __use__ = ('comment',)
       
    53 
       
    54 will make the ``Comment`` entity available in your ``BlogDemo``
       
    55 cube.
       
    56 
       
    57 Change the schema to add a relationship between ``BlogEntry`` and
       
    58 ``Comment`` and you are done. Since the comment cube defines the
       
    59 ``comments`` relationship, adding the line::
       
    60 
       
    61     comments = ObjectRelation('Comment', cardinality='1*', composite='object')
       
    62 
       
    63 to the definition of a ``BlogEntry`` will be enough.
       
    64 
       
    65 Synchronize the data model
       
    66 ~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    67 
       
    68 Once you modified your data model, you need to synchronize the
       
    69 database with your model. For this purpose, *CubicWeb* provides
       
    70 a very useful command ``cubicweb-ctl shell blogdemo`` which
       
    71 launches an interactive shell where you can enter migration
       
    72 commands (see :ref:`cubicweb-ctl` for more details)).
       
    73 As you added the cube named `comment`, you need to run:
       
    74 
       
    75 ::
       
    76 
       
    77   add_cube('comment')
       
    78 
       
    79 You can now start your instance and comment your blog entries.