doc/book/devrepo/cubes/cc-newcube.rst
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 28 Jan 2016 18:17:30 +0100
changeset 11090 b4b854c25de5
parent 10517 fa9a0c80556d
child 11687 f9efc8012b64
permissions -rw-r--r--
[repository] set .eid on eschema when schema is loaded from the filesystem enforcing the contract that a repository's schema should have .eid attribute of entity schema set to the eid of the entity used to serialize them in the db. Before this cset, this was not true during tests or for some c-c commands where 'quick_start' is set (eg db-restore, i18ncube...). The change in server __init__ makes this assumption true during instance creation: the serializing code was actually setting eid on schema object, but a reference to a previously built schema was given instead of the one for the latest created repository. Closes #10450092
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6928
62b8ef1e859a [doc/book] simplify & fix the overview chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5608
diff changeset
     1
Creating a new cube from scratch
62b8ef1e859a [doc/book] simplify & fix the overview chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5608
diff changeset
     2
--------------------------------
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     3
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     4
Let's start by creating the cube environment in which we will develop ::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     5
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
     6
  cd ~/cubes
4437
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2280
diff changeset
     7
  # use cubicweb-ctl to generate a template for the cube
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
     8
  # will ask some questions, most with nice default
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
     9
  cubicweb-ctl newcube mycube
4437
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2280
diff changeset
    10
  # makes the cube source code managed by mercurial
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    11
  cd mycube
4437
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2280
diff changeset
    12
  hg init
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    13
  hg add .
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    14
  hg ci
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    15
2280
31269a9b9ec4 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    16
If all went well, you should see the cube you just created in the list
6928
62b8ef1e859a [doc/book] simplify & fix the overview chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5608
diff changeset
    17
returned by ``cubicweb-ctl list`` in the  *Available cubes* section.
5608
f9ab62103ad4 proof read documentation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 5400
diff changeset
    18
If not, please refer to :ref:`ConfigurationEnv`.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    19
5400
b7ab099b128a [doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5394
diff changeset
    20
To reuse an existing cube, add it to the list named
5608
f9ab62103ad4 proof read documentation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 5400
diff changeset
    21
``__depends_cubes__`` which is defined in :file:`__pkginfo__.py`.
f9ab62103ad4 proof read documentation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 5400
diff changeset
    22
This variable is used for the instance packaging (dependencies handled
f9ab62103ad4 proof read documentation
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 5400
diff changeset
    23
by system utility tools such as APT) and to find used cubes when the
10517
fa9a0c80556d [schema] drop old backward compat code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10491
diff changeset
    24
database for the instance is created.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    25
6928
62b8ef1e859a [doc/book] simplify & fix the overview chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5608
diff changeset
    26
On a Unix system, the available cubes are usually stored in the
62b8ef1e859a [doc/book] simplify & fix the overview chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5608
diff changeset
    27
directory :file:`/usr/share/cubicweb/cubes`. If you are using the
62b8ef1e859a [doc/book] simplify & fix the overview chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5608
diff changeset
    28
cubicweb mercurial repository (:ref:`SourceInstallation`), the cubes
62b8ef1e859a [doc/book] simplify & fix the overview chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5608
diff changeset
    29
are searched in the directory
62b8ef1e859a [doc/book] simplify & fix the overview chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5608
diff changeset
    30
:file:`/path/to/cubicweb_toplevel/cubes`. In this configuration
62b8ef1e859a [doc/book] simplify & fix the overview chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5608
diff changeset
    31
cubicweb itself ought to be located at
62b8ef1e859a [doc/book] simplify & fix the overview chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5608
diff changeset
    32
:file:`/path/to/cubicweb_toplevel/cubicweb`.
62b8ef1e859a [doc/book] simplify & fix the overview chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5608
diff changeset
    33
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    34
.. note::
4437
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2280
diff changeset
    35
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2280
diff changeset
    36
    Please note that if you do not wish to use default directory for your cubes
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2280
diff changeset
    37
    library, you should set the :envvar:`CW_CUBES_PATH` environment variable to
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2280
diff changeset
    38
    add extra directories where cubes will be search, and you'll then have to use
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2280
diff changeset
    39
    the option `--directory` to specify where you would like to place the source
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2280
diff changeset
    40
    code of your cube:
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2280
diff changeset
    41
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2280
diff changeset
    42
    ``cubicweb-ctl newcube --directory=/path/to/cubes/library mycube``
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    43
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
    44
4437
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2280
diff changeset
    45
.. XXX resurrect once live-server is back
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2280
diff changeset
    46
.. Usage of :command:`cubicweb-ctl liveserver`
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2280
diff changeset
    47
.. -------------------------------------------
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    48
4437
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2280
diff changeset
    49
.. To quickly test a new cube, you can also use the `liveserver` command for cubicweb-ctl
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2280
diff changeset
    50
.. which allows to create an instance in memory (using an SQLite database by
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2280
diff changeset
    51
.. default) and make it accessible through a web server ::
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    52
4437
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2280
diff changeset
    53
..   cubicweb-ctl live-server mycube
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    54
4437
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2280
diff changeset
    55
.. or by using an existing database (SQLite or Postgres)::
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    56
4437
21f2e01fdd6a update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2280
diff changeset
    57
..   cubicweb-ctl live-server -s myfile_sources mycube