doc/tutorials/advanced/part01_create-cube.rst
author Laurent Peuch <cortex@worlddomination.be>
Thu, 21 Feb 2019 19:08:44 +0100
changeset 12402 e4da2575ac37
parent 12394 e847b5d1ffff
child 12403 d901fc62eb01
permissions -rw-r--r--
[doc] correct pip command to have needed dependancies to use the start command I know we want to remove this command but in the meantime having this documentation working seems like something good.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     1
.. _TutosPhotoWebSiteCubeCreation:
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     2
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     3
Cube creation and schema definition
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     4
-----------------------------------
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     5
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     6
.. _adv_tuto_create_new_cube:
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     7
12209
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
     8
Step 1: creating a virtual environment
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
     9
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    10
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    11
Fisrt I need a python virtual environment with cubicweb::
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    12
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    13
  virtualenv python-2.7.5_cubicweb
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    14
  . /python-2.7.5_cubicweb/bin/activate
12402
e4da2575ac37 [doc] correct pip command to have needed dependancies to use the start command
Laurent Peuch <cortex@worlddomination.be>
parents: 12394
diff changeset
    15
  pip install cubicweb[etwist]
12209
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    16
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    17
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    18
Step 2: creating a new cube for my web site
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    19
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    20
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    21
One note about my development environment: I wanted to use the packaged
12209
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    22
version of CubicWeb and cubes while keeping my cube in the current
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    23
directory, let's say `~src/cubes`::
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    24
12209
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    25
  cd ~src/cubes
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    26
  CW_MODE=user
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    27
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    28
I can now create the cube which will hold custom code for this web
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    29
site using::
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    30
12209
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    31
  cubicweb-ctl newcube sytweb
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    32
12389
385a1d11dfeb [doc] make this step more obvious
Laurent Peuch <cortex@worlddomination.be>
parents: 12388
diff changeset
    33
Enter a short description and this will create your new cube in the
385a1d11dfeb [doc] make this step more obvious
Laurent Peuch <cortex@worlddomination.be>
parents: 12388
diff changeset
    34
`cubicweb-sytweb` folder.
385a1d11dfeb [doc] make this step more obvious
Laurent Peuch <cortex@worlddomination.be>
parents: 12388
diff changeset
    35
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    36
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    37
.. _adv_tuto_assemble_cubes:
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    38
12209
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    39
Step 3: pick building blocks into existing cubes
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    40
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    41
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    42
Almost everything I want to handle in my web-site is somehow already modelized in
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    43
existing cubes that I'll extend for my need. So I'll pick the following cubes:
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    44
12390
d9196c0420fe [doc] add a link to every cube documentation page
Laurent Peuch <cortex@worlddomination.be>
parents: 12389
diff changeset
    45
* `folder <https://www.cubicweb.org/project/cubicweb-folder>`_, containing the
d9196c0420fe [doc] add a link to every cube documentation page
Laurent Peuch <cortex@worlddomination.be>
parents: 12389
diff changeset
    46
  `Folder` entity type, which will be used as both 'album' and a way to map
d9196c0420fe [doc] add a link to every cube documentation page
Laurent Peuch <cortex@worlddomination.be>
parents: 12389
diff changeset
    47
  file system folders. Entities are added to a given folder using the
d9196c0420fe [doc] add a link to every cube documentation page
Laurent Peuch <cortex@worlddomination.be>
parents: 12389
diff changeset
    48
  `filed_under` relation.
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    49
12390
d9196c0420fe [doc] add a link to every cube documentation page
Laurent Peuch <cortex@worlddomination.be>
parents: 12389
diff changeset
    50
* `file <https://www.cubicweb.org/project/cubicweb-file>`_, containing `File`
d9196c0420fe [doc] add a link to every cube documentation page
Laurent Peuch <cortex@worlddomination.be>
parents: 12389
diff changeset
    51
  entity type, gallery view, and a file system import utility.
d9196c0420fe [doc] add a link to every cube documentation page
Laurent Peuch <cortex@worlddomination.be>
parents: 12389
diff changeset
    52
d9196c0420fe [doc] add a link to every cube documentation page
Laurent Peuch <cortex@worlddomination.be>
parents: 12389
diff changeset
    53
* `zone <https://www.cubicweb.org/project/cubicweb-zone>`_, containing the
d9196c0420fe [doc] add a link to every cube documentation page
Laurent Peuch <cortex@worlddomination.be>
parents: 12389
diff changeset
    54
  `Zone` entity type for hierarchical geographical zones. Entities (including
d9196c0420fe [doc] add a link to every cube documentation page
Laurent Peuch <cortex@worlddomination.be>
parents: 12389
diff changeset
    55
  sub-zones) are added to a given zone using the `situated_in` relation.
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    56
12390
d9196c0420fe [doc] add a link to every cube documentation page
Laurent Peuch <cortex@worlddomination.be>
parents: 12389
diff changeset
    57
* `person <https://www.cubicweb.org/project/cubicweb-person>`_, containing the
d9196c0420fe [doc] add a link to every cube documentation page
Laurent Peuch <cortex@worlddomination.be>
parents: 12389
diff changeset
    58
  `Person` entity type plus some basic views.
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    59
12390
d9196c0420fe [doc] add a link to every cube documentation page
Laurent Peuch <cortex@worlddomination.be>
parents: 12389
diff changeset
    60
* `comment <https://www.cubicweb.org/project/cubicweb-comment>`_, providing a
d9196c0420fe [doc] add a link to every cube documentation page
Laurent Peuch <cortex@worlddomination.be>
parents: 12389
diff changeset
    61
  full commenting system allowing one to comment entity types supporting the
d9196c0420fe [doc] add a link to every cube documentation page
Laurent Peuch <cortex@worlddomination.be>
parents: 12389
diff changeset
    62
  `comments` relation by adding a `Comment` entity.
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    63
12390
d9196c0420fe [doc] add a link to every cube documentation page
Laurent Peuch <cortex@worlddomination.be>
parents: 12389
diff changeset
    64
* `tag <https://www.cubicweb.org/project/cubicweb-tag>`_, providing a full
d9196c0420fe [doc] add a link to every cube documentation page
Laurent Peuch <cortex@worlddomination.be>
parents: 12389
diff changeset
    65
  tagging system as an easy and powerful way to classify entities supporting
d9196c0420fe [doc] add a link to every cube documentation page
Laurent Peuch <cortex@worlddomination.be>
parents: 12389
diff changeset
    66
  the `tags` relation by linking the to `Tag` entities. This will allows
d9196c0420fe [doc] add a link to every cube documentation page
Laurent Peuch <cortex@worlddomination.be>
parents: 12389
diff changeset
    67
  navigation into a large number of picture.
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    68
12209
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    69
Ok, now I'll tell my cube requires all this by editing :file:`cubicweb-sytweb/cubicweb_sytweb/__pkginfo__.py`:
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    70
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    71
  .. sourcecode:: python
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    72
12388
83269385a51d [doc] move to latest CW version for cube creation
Laurent Peuch <cortex@worlddomination.be>
parents: 12209
diff changeset
    73
    __depends__ = {'cubicweb': '>= 3.26.7',
6923
327443ec7120 [doc] update photo web site tutorial: we're starting from cw 3.10/file 1.9+
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6876
diff changeset
    74
                   'cubicweb-file': '>= 1.9.0',
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    75
		   'cubicweb-folder': '>= 1.1.0',
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    76
		   'cubicweb-person': '>= 1.2.0',
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    77
		   'cubicweb-comment': '>= 1.2.0',
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    78
		   'cubicweb-tag': '>= 1.2.0',
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    79
		   'cubicweb-zone': None}
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    80
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    81
Notice that you can express minimal version of the cube that should be used,
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    82
`None` meaning whatever version available. All packages starting with 'cubicweb-'
12209
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    83
will be recognized as being cube, not bare python packages.
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    84
6923
327443ec7120 [doc] update photo web site tutorial: we're starting from cw 3.10/file 1.9+
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6876
diff changeset
    85
If your cube is packaged for debian, it's a good idea to update the
327443ec7120 [doc] update photo web site tutorial: we're starting from cw 3.10/file 1.9+
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6876
diff changeset
    86
`debian/control` file at the same time, so you won't forget it.
327443ec7120 [doc] update photo web site tutorial: we're starting from cw 3.10/file 1.9+
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6876
diff changeset
    87
12209
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    88
Now, I need to install all the dependencies::
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    89
12209
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    90
  cd cubicweb-sytweb
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    91
  pip install -e .
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    92
  pip install cubicweb[etwist]
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    93
  pip install psycopg2 # for postgresql
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    94
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    95
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
    96
Step 4: glue everything together in my cube's schema
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    97
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    98
12394
e847b5d1ffff [doc] always put file name for code example and uses :file:`path` syntax everywhere
Laurent Peuch <cortex@worlddomination.be>
parents: 12393
diff changeset
    99
Put this code in :file:`cubicweb-sytweb/cubicweb_sytweb/schema.py`:
e847b5d1ffff [doc] always put file name for code example and uses :file:`path` syntax everywhere
Laurent Peuch <cortex@worlddomination.be>
parents: 12393
diff changeset
   100
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   101
.. sourcecode:: python
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   102
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   103
    from yams.buildobjs import RelationDefinition
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   104
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   105
    class comments(RelationDefinition):
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   106
	subject = 'Comment'
6923
327443ec7120 [doc] update photo web site tutorial: we're starting from cw 3.10/file 1.9+
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6876
diff changeset
   107
	object = 'File'
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   108
	cardinality = '1*'
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   109
	composite = 'object'
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   110
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   111
    class tags(RelationDefinition):
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   112
	subject = 'Tag'
6923
327443ec7120 [doc] update photo web site tutorial: we're starting from cw 3.10/file 1.9+
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6876
diff changeset
   113
	object = 'File'
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   114
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   115
    class filed_under(RelationDefinition):
6923
327443ec7120 [doc] update photo web site tutorial: we're starting from cw 3.10/file 1.9+
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6876
diff changeset
   116
	subject = 'File'
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   117
	object = 'Folder'
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   118
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   119
    class situated_in(RelationDefinition):
6923
327443ec7120 [doc] update photo web site tutorial: we're starting from cw 3.10/file 1.9+
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6876
diff changeset
   120
	subject = 'File'
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   121
	object = 'Zone'
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   122
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   123
    class displayed_on(RelationDefinition):
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   124
	subject = 'Person'
6923
327443ec7120 [doc] update photo web site tutorial: we're starting from cw 3.10/file 1.9+
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6876
diff changeset
   125
	object = 'File'
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   126
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   127
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   128
This schema:
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   129
6923
327443ec7120 [doc] update photo web site tutorial: we're starting from cw 3.10/file 1.9+
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6876
diff changeset
   130
* allows to comment and tag on `File` entity type by adding the `comments` and
327443ec7120 [doc] update photo web site tutorial: we're starting from cw 3.10/file 1.9+
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6876
diff changeset
   131
  `tags` relations. This should be all we've to do for this feature since the
327443ec7120 [doc] update photo web site tutorial: we're starting from cw 3.10/file 1.9+
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6876
diff changeset
   132
  related cubes provide 'pluggable section' which are automatically displayed on
327443ec7120 [doc] update photo web site tutorial: we're starting from cw 3.10/file 1.9+
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6876
diff changeset
   133
  the primary view of entity types supporting the relation.
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   134
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   135
* adds a `situated_in` relation definition so that image entities can be
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   136
  geolocalized.
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   137
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   138
* add a new relation `displayed_on` relation telling who can be seen on a
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   139
  picture.
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   140
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   141
This schema will probably have to evolve as time goes (for security handling at
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   142
least), but since the possibility to let a schema evolve is one of CubicWeb's
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   143
features (and goals), we won't worry about it for now and see that later when needed.
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   144
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   145
12209
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
   146
Step 5: creating the instance
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   147
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   148
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   149
Now that I have a schema, I want to create an instance. To
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   150
do so using this new 'sytweb' cube, I run::
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   151
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   152
  cubicweb-ctl create sytweb sytweb_instance
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   153
12391
e4e5814fd70c [doc] recommend sqlite during tutorial because it's simplier to use
Laurent Peuch <cortex@worlddomination.be>
parents: 12390
diff changeset
   154
For simplicity you should use the sqlite database, it won't require
e4e5814fd70c [doc] recommend sqlite during tutorial because it's simplier to use
Laurent Peuch <cortex@worlddomination.be>
parents: 12390
diff changeset
   155
configuration.
e4e5814fd70c [doc] recommend sqlite during tutorial because it's simplier to use
Laurent Peuch <cortex@worlddomination.be>
parents: 12390
diff changeset
   156
12209
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
   157
Don't forget to say "yes" to the question: `Allow anonymous access ? [y/N]:`
3a3551fff787 [doc] Update the advanced tutorial
Olivier Giorgis <olivier.giorgis@logilab.fr>
parents: 10491
diff changeset
   158
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   159
Hint: if you get an error while the database is initialized, you can
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   160
avoid having to answer the questions again by running::
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   161
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   162
   cubicweb-ctl db-create sytweb_instance
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   163
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   164
This will use your already configured instance and start directly from the create
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   165
database step, thus skipping questions asked by the 'create' command.
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   166
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   167
Once the instance and database are fully initialized, run ::
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   168
12392
ab8613334697 [doc] start the server in debug mode, it's easier during learning
Laurent Peuch <cortex@worlddomination.be>
parents: 12391
diff changeset
   169
  cubicweb-ctl start -D sytweb_instance
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   170
12393
ea198374785b [doc] explicitely give the local server url to make this step more obvious
Laurent Peuch <cortex@worlddomination.be>
parents: 12392
diff changeset
   171
to start the instance, check you can connect on it, etc... then go on
ea198374785b [doc] explicitely give the local server url to make this step more obvious
Laurent Peuch <cortex@worlddomination.be>
parents: 12392
diff changeset
   172
http://localhost:8080 (or with another port if you've modified it)