doc/book/en/development/cubes/layout.rst
branchtls-sprint
changeset 1714 a721966779be
child 2476 1294a6bdf3bf
equal deleted inserted replaced
1499:fd8751c3f3ee 1714:a721966779be
       
     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   |   `-- fr.po
       
    33   |
       
    34   |-- __init__.py
       
    35   |
       
    36   |-- MANIFEST.in
       
    37   |
       
    38   |-- migration/
       
    39   |   |-- postcreate.py
       
    40   |   `-- precreate.py
       
    41   |
       
    42   |-- __pkginfo__.py
       
    43   |
       
    44   |-- schema.py
       
    45   |
       
    46   |-- setup.py
       
    47   |
       
    48   |-- site_cubicweb.py
       
    49   |
       
    50   |-- hooks.py
       
    51   |
       
    52   |-- test/
       
    53   |   |-- data/
       
    54   |   |   `-- bootstrap_cubes
       
    55   |   |-- pytestconf.py
       
    56   |   |-- realdb_test_mycube.py
       
    57   |   `-- test_mycube.py
       
    58   |
       
    59   `-- views.py
       
    60 
       
    61 
       
    62 We can use subpackages instead of python modules for ``views.py``, ``entities.py``,
       
    63 ``schema.py`` or ``hooks.py``. For example, we could have:
       
    64 
       
    65 ::
       
    66 
       
    67   mycube/
       
    68   |
       
    69   |-- entities.py
       
    70   |-- hooks.py
       
    71   `-- views/
       
    72       |-- forms.py
       
    73       |-- primary.py
       
    74       `-- widgets.py
       
    75 
       
    76 
       
    77 where :
       
    78 
       
    79 * ``schema`` contains the schema definition (server side only)
       
    80 * ``entities`` contains the entities definition (server side and web interface)
       
    81 * ``sobjects`` contains hooks and/or views notifications (server side only)
       
    82 * ``views`` contains the web interface components (web interface only)
       
    83 * ``test`` contains tests related to the application (not installed)
       
    84 * ``i18n`` contains message catalogs for supported languages (server side and
       
    85   web interface)
       
    86 * ``data`` contains data files for static content (images, css, javascripts)
       
    87   ...(web interface only)
       
    88 * ``migration`` contains initialization files for new instances (``postcreate.py``)
       
    89   and a file containing dependencies of the component depending on the version
       
    90   (``depends.map``)
       
    91 * ``debian`` contains all the files managing debian packaging (you will find
       
    92   the usual files ``control``, ``rules``, ``changelog``... not installed)
       
    93 * file ``__pkginfo__.py`` provides component meta-data, especially the distribution
       
    94   and the current version (server side and web interface) or sub-cubes used by
       
    95   the cube.
       
    96 
       
    97 
       
    98 At least you should have:
       
    99 
       
   100 * the file ``__pkginfo__.py``
       
   101 * the schema definition
       
   102   XXX false, we may want to have cubes which are only adding a service,
       
   103   no persistent data (eg embedding for instance)
       
   104 
       
   105 
       
   106 
       
   107 The :file:`__init__.py` and :file:`site_cubicweb.py` files
       
   108 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   109 
       
   110 The :file:`__pkginfo__.py` file
       
   111 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   112 XXX contains metadata describing your cubes
       
   113     distname / modname
       
   114     version / numversion
       
   115     __use__
       
   116     __recommend__
       
   117 
       
   118 
       
   119 :file:`migration/precreate.py` and :file:`migration/postcreate.py`
       
   120 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   121 XXX detail steps of instance creation
       
   122 
       
   123 
       
   124 External resources such as image, javascript and css files
       
   125 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   126 XXX naming convention external_resources file
       
   127 
       
   128 
       
   129 Out-of the box testing
       
   130 ~~~~~~~~~~~~~~~~~~~~~~
       
   131 XXX MANIFEST.in, __pkginfo__.include_dirs, debian
       
   132 
       
   133 
       
   134 
       
   135 Packaging and distribution
       
   136 ~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   137 XXX MANIFEST.in, __pkginfo__.include_dirs, debian
       
   138