doc/book/en/development/cubes/layout.rst
brancholdstable
changeset 5422 0865e1e90674
parent 4985 02b52bf9f5f8
parent 5421 8167de96c523
child 5424 8ecbcbff9777
equal deleted inserted replaced
4985:02b52bf9f5f8 5422:0865e1e90674
     1 
       
     2 .. _foundationsCube:
       
     3 
       
     4 .. _cubelayout:
       
     5 
       
     6 Standard structure for a cube
       
     7 -----------------------------
       
     8 
       
     9 A cube is structured as follows:
       
    10 
       
    11 ::
       
    12 
       
    13   mycube/
       
    14   |
       
    15   |-- data/
       
    16   |   |-- cubes.mycube.css
       
    17   |   |-- cubes.mycube.js
       
    18   |   `-- external_resources
       
    19   |
       
    20   |-- debian/
       
    21   |   |-- changelog
       
    22   |   |-- compat
       
    23   |   |-- control
       
    24   |   |-- copyright
       
    25   |   |-- cubicweb-mycube.prerm
       
    26   |   `-- rules
       
    27   |
       
    28   |-- entities.py
       
    29   |
       
    30   |-- i18n/
       
    31   |   |-- en.po
       
    32   |   |-- es.po
       
    33   |   `-- fr.po
       
    34   |
       
    35   |-- __init__.py
       
    36   |
       
    37   |-- MANIFEST.in
       
    38   |
       
    39   |-- migration/
       
    40   |   |-- postcreate.py
       
    41   |   `-- precreate.py
       
    42   |
       
    43   |-- __pkginfo__.py
       
    44   |
       
    45   |-- schema.py
       
    46   |
       
    47   |-- setup.py
       
    48   |
       
    49   |-- site_cubicweb.py
       
    50   |
       
    51   |-- hooks.py
       
    52   |
       
    53   |-- test/
       
    54   |   |-- data/
       
    55   |   |   `-- bootstrap_cubes
       
    56   |   |-- pytestconf.py
       
    57   |   |-- realdb_test_mycube.py
       
    58   |   `-- test_mycube.py
       
    59   |
       
    60   `-- views.py
       
    61 
       
    62 
       
    63 We can use subpackages instead of python modules for ``views.py``, ``entities.py``,
       
    64 ``schema.py`` or ``hooks.py``. For example, we could have:
       
    65 
       
    66 ::
       
    67 
       
    68   mycube/
       
    69   |
       
    70   |-- entities.py
       
    71   |-- hooks.py
       
    72   `-- views/
       
    73       |-- forms.py
       
    74       |-- primary.py
       
    75       `-- widgets.py
       
    76 
       
    77 
       
    78 where :
       
    79 
       
    80 * ``schema`` contains the schema definition (server side only)
       
    81 * ``entities`` contains the entities definition (server side and web interface)
       
    82 * ``hooks`` contains hooks and/or views notifications (server side only)
       
    83 * ``views`` contains the web interface components (web interface only)
       
    84 * ``test`` contains tests related to the cube (not installed)
       
    85 * ``i18n`` contains message catalogs for supported languages (server side and
       
    86   web interface)
       
    87 * ``data`` contains data files for static content (images, css, javascripts)
       
    88   ...(web interface only)
       
    89 * ``migration`` contains initialization files for new instances (``postcreate.py``)
       
    90   and a file containing dependencies of the component depending on the version
       
    91   (``depends.map``)
       
    92 * ``debian`` contains all the files managing debian packaging (you will find
       
    93   the usual files ``control``, ``rules``, ``changelog``... not installed)
       
    94 * file ``__pkginfo__.py`` provides component meta-data, especially the distribution
       
    95   and the current version (server side and web interface) or sub-cubes used by
       
    96   the cube.
       
    97 
       
    98 
       
    99 At least you should have:
       
   100 
       
   101 * the file ``__pkginfo__.py``
       
   102 * the schema definition
       
   103   XXX false, we may want to have cubes which are only adding a service,
       
   104   no persistent data (eg embedding for instance)
       
   105 
       
   106 
       
   107 
       
   108 The :file:`__init__.py` and :file:`site_cubicweb.py` files
       
   109 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   110 
       
   111 The :file:`__pkginfo__.py` file
       
   112 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   113 XXX contains metadata describing your cubes
       
   114     distname / modname
       
   115     version / numversion
       
   116     __use__
       
   117     __recommend__
       
   118 
       
   119 
       
   120 :file:`migration/precreate.py` and :file:`migration/postcreate.py`
       
   121 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   122 XXX detail steps of instance creation
       
   123 
       
   124 
       
   125 External resources such as image, javascript and css files
       
   126 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   127 XXX naming convention external_resources file
       
   128 
       
   129 
       
   130 Out-of the box testing
       
   131 ~~~~~~~~~~~~~~~~~~~~~~
       
   132 XXX MANIFEST.in, __pkginfo__.include_dirs, debian
       
   133 
       
   134 
       
   135 
       
   136 Packaging and distribution
       
   137 ~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   138 XXX MANIFEST.in, __pkginfo__.include_dirs, debian
       
   139