doc/book/devrepo/cubes/cc-newcube.rst
changeset 10491 c67bcee93248
parent 6928 62b8ef1e859a
child 10517 fa9a0c80556d
equal deleted inserted replaced
10490:76ab3c71aff2 10491:c67bcee93248
       
     1 Creating a new cube from scratch
       
     2 --------------------------------
       
     3 
       
     4 Let's start by creating the cube environment in which we will develop ::
       
     5 
       
     6   cd ~/cubes
       
     7   # use cubicweb-ctl to generate a template for the cube
       
     8   # will ask some questions, most with nice default
       
     9   cubicweb-ctl newcube mycube
       
    10   # makes the cube source code managed by mercurial
       
    11   cd mycube
       
    12   hg init
       
    13   hg add .
       
    14   hg ci
       
    15 
       
    16 If all went well, you should see the cube you just created in the list
       
    17 returned by ``cubicweb-ctl list`` in the  *Available cubes* section.
       
    18 If not, please refer to :ref:`ConfigurationEnv`.
       
    19 
       
    20 To reuse an existing cube, add it to the list named
       
    21 ``__depends_cubes__`` which is defined in :file:`__pkginfo__.py`.
       
    22 This variable is used for the instance packaging (dependencies handled
       
    23 by system utility tools such as APT) and to find used cubes when the
       
    24 database for the instance is created (import_erschema('MyCube') will
       
    25 not properly work otherwise).
       
    26 
       
    27 On a Unix system, the available cubes are usually stored in the
       
    28 directory :file:`/usr/share/cubicweb/cubes`. If you are using the
       
    29 cubicweb mercurial repository (:ref:`SourceInstallation`), the cubes
       
    30 are searched in the directory
       
    31 :file:`/path/to/cubicweb_toplevel/cubes`. In this configuration
       
    32 cubicweb itself ought to be located at
       
    33 :file:`/path/to/cubicweb_toplevel/cubicweb`.
       
    34 
       
    35 .. note::
       
    36 
       
    37     Please note that if you do not wish to use default directory for your cubes
       
    38     library, you should set the :envvar:`CW_CUBES_PATH` environment variable to
       
    39     add extra directories where cubes will be search, and you'll then have to use
       
    40     the option `--directory` to specify where you would like to place the source
       
    41     code of your cube:
       
    42 
       
    43     ``cubicweb-ctl newcube --directory=/path/to/cubes/library mycube``
       
    44 
       
    45 
       
    46 .. XXX resurrect once live-server is back
       
    47 .. Usage of :command:`cubicweb-ctl liveserver`
       
    48 .. -------------------------------------------
       
    49 
       
    50 .. To quickly test a new cube, you can also use the `liveserver` command for cubicweb-ctl
       
    51 .. which allows to create an instance in memory (using an SQLite database by
       
    52 .. default) and make it accessible through a web server ::
       
    53 
       
    54 ..   cubicweb-ctl live-server mycube
       
    55 
       
    56 .. or by using an existing database (SQLite or Postgres)::
       
    57 
       
    58 ..   cubicweb-ctl live-server -s myfile_sources mycube