doc/book/en/development/datamodel/definition.rst
author Aurelien Campeas <aurelien.campeas@logilab.fr>
Mon, 12 Apr 2010 16:49:35 +0200
branchstable
changeset 5220 42f854b6083d
parent 5145 bfa4d775219f
child 5319 9b1b7020d179
permissions -rw-r--r--
[doc/book] complete chapter on hooks & ops
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4452
5d6dec2c4650 [doc] small fixes on security part
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3811
diff changeset
     1
 .. -*- coding: utf-8 -*-
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     2
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     3
Yams *schema*
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     4
-------------
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     5
2476
1294a6bdf3bf application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2175
diff changeset
     6
The **schema** is the core piece of a *CubicWeb* instance as it defines
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     7
the handled data model. It is based on entity types that are either already
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: 4430
diff changeset
     8
defined in the *CubicWeb* standard library; or more specific types defined
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: 4430
diff changeset
     9
in cubes. The schema for a cube is defined in a :file:schema.py file or in
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: 4430
diff changeset
    10
one or more Python files under the :file:`schema` directory (python package).
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    11
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    12
At this point, it is important to make clear the difference between
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    13
*relation type* and *relation definition*: a *relation type* is only a relation
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    14
name with potentially other additional properties (see below), whereas a
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
    15
*relation definition* is a complete triplet
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
    16
"<subject entity type> <relation type> <object entity type>".
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    17
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    18
Also, it should be clear that to properly handle data migration, an
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    19
instance's schema
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    20
is stored in the database, so the python schema file used to defined it is only read
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: 4430
diff changeset
    21
when the instance is created or upgraded.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    22
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    23
The following built-in types are available: `String`, `Int`, `Float`,
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
    24
`Decimal`, `Boolean`, `Date`, `Datetime`, `Time`, `Interval`, `Byte`
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    25
and `Password`.
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: 4430
diff changeset
    26
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    27
You'll also have access to :ref:`base CubicWeb entity types <CWBaseEntityTypes>`.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    28
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: 4430
diff changeset
    29
The instance schema is accessible through the .schema attribute of the
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: 4430
diff changeset
    30
`vregistry`.  It's an instance of :class:`cubicweb.schema.Schema`, which
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: 4430
diff changeset
    31
extends :class:`yams.schema.Schema`.
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: 4430
diff changeset
    32
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: 4430
diff changeset
    33
:note:
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: 4430
diff changeset
    34
  In previous yams versions, almost all classes where available without
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    35
  any import, but the should now be explicitly imported.
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: 4430
diff changeset
    36
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    37
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    38
Entity type
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    39
~~~~~~~~~~~
5220
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
    40
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    41
An entity type is an instance of :class:`yams.schema.EntitySchema`. Each entity type has
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    42
a set of attributes and relations, and some permissions which define who can add, read,
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: 4430
diff changeset
    43
update or delete entities of this type.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    44
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    45
XXX yams inheritance
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    46
5220
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
    47
.. _RelationType:
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
    48
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    49
Relation type
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    50
~~~~~~~~~~~~~
5220
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
    51
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    52
A relation type is an instance of :class:`yams.schema.RelationSchema`. A relation type is simply
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    53
a semantic definition of a kind of relationship that may occur in an application.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    54
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    55
It is important to choose a good name, at least to avoid conflicts with some semantically
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    56
different relation defined in other cubes (since we've no name space yet).
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    57
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    58
A relation type holds the following properties (which are hence shared between all
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: 4430
diff changeset
    59
relation definitions of that type):
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    60
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    61
* `inlined`: boolean handling the physical optimization for archiving
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    62
  the relation in the subject entity table, instead of creating a specific
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: 4430
diff changeset
    63
  table for the relation. This applies to relations where cardinality
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: 4430
diff changeset
    64
  of subject->relation->object is 0..1 (`?`) or 1..1 (`1`) for *all* its relation
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: 4430
diff changeset
    65
  definitions.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    66
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    67
* `symmetric`: boolean indicating that the relation is symmetrical, which
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: 4430
diff changeset
    68
  means that `X relation Y` implies `Y relation X`.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    69
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    70
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    71
Relation definition
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    72
~~~~~~~~~~~~~~~~~~~
5220
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
    73
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    74
A relation definition is an instance of :class:`yams.schema.RelationDefinition`. It is a complete triplet
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: 4430
diff changeset
    75
"<subject entity type> <relation type> <object entity type>".
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    76
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    77
When creating a new instance of that class, the corresponding
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    78
:class:`RelationType` instance is created on the fly if necessary.
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    79
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    80
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    81
Properties
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    82
``````````
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    83
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    84
* Optional properties for attributes and relations:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    85
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    86
  - `description`: a string describing an attribute or a relation. By default
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    87
    this string will be used in the editing form of the entity, which means
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    88
    that it is supposed to help the end-user and should be flagged by the
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    89
    function `_` to be properly internationalized.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    90
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    91
  - `constraints`: a list of conditions/constraints that the relation has to
3581
669854258b90 [doc] various fixes
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 3283
diff changeset
    92
    satisfy (c.f. `Constraints`_)
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    93
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    94
  - `cardinality`: a two character string specifying the cardinality of the
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    95
    relation. The first character defines the cardinality of the relation on
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
    96
    the subject, and the second on the object. When a relation can have
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    97
    multiple subjects or objects, the cardinality applies to all,
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    98
    not on a one-to-one basis (so it must be consistent...). The possible
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
    99
    values are inspired from regular expression syntax:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   100
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   101
    * `1`: 1..1
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   102
    * `?`: 0..1
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   103
    * `+`: 1..n
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   104
    * `*`: 0..n
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   105
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   106
* optional properties for attributes:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   107
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   108
  - `unique`: boolean indicating if the value of the attribute has to be unique
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   109
    or not within all entities of the same type (false by default)
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   110
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   111
  - `indexed`: boolean indicating if an index needs to be created for this
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   112
    attribute in the database (false by default). This is useful only if
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   113
    you know that you will have to run numerous searches on the value of this
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   114
    attribute.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   115
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   116
  - `default`: default value of the attribute. In case of date types, the values
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   117
    which could be used correspond to the RQL keywords `TODAY` and `NOW`.
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
   118
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   119
* optional properties for type `String` attributes:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   120
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   121
  - `fulltextindexed`: boolean indicating if the attribute is part of
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   122
    the full text index (false by default) (*applicable on the type `Byte`
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   123
    as well*)
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   124
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   125
  - `internationalizable`: boolean indicating if the value of the attribute
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   126
    is internationalizable (false by default)
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   127
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   128
* optional properties for relations:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   129
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   130
  - `composite`: string indicating that the subject (composite == 'subject')
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   131
    is composed of the objects of the relations. For the opposite case (when
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
   132
    the object is composed of the subjects of the relation), we just set
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   133
    'object' as value. The composition implies that when the relation
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: 4430
diff changeset
   134
    is deleted (so when the composite is deleted, at least), the composed are also deleted.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   135
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   136
  - `fulltext_container`: string indicating if the value if the full text
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   137
    indexation of the entity on one end of the relation should be used
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   138
    to find the entity on the other end. The possible values are
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   139
    'subject' or 'object'. For instance the use_email relation has
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   140
    that property set to 'subject', since when performing a full text
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   141
    search people want to find the entity using an email address, and not
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   142
    the entity representing the email address.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   143
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   144
Constraints
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   145
```````````
4032
c3a018efe7c9 Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 3811
diff changeset
   146
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   147
By default, the available constraint types are:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   148
4032
c3a018efe7c9 Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 3811
diff changeset
   149
General Constraints
c3a018efe7c9 Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 3811
diff changeset
   150
......................
c3a018efe7c9 Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 3811
diff changeset
   151
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   152
* `SizeConstraint`: allows to specify a minimum and/or maximum size on
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   153
  string (generic case of `maxsize`)
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   154
5220
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
   155
* `BoundConstraint`: allows to specify a minimum and/or maximum value
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
   156
  on numeric types and date
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
   157
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
   158
.. sourcecode:: python
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
   159
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
   160
   from yams.constraints import BoundConstraint, TODAY
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
   161
   BoundConstraint('<=', TODAY())
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
   162
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
   163
* `IntervalBoundConstraint`: allows to specify an interval with
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
   164
  included values
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
   165
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
   166
.. sourcecode:: python
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
   167
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
   168
     class Node(EntityType):
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
   169
         latitude = Float(constraints=[IntervalBoundConstraint(-90, +90)])
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   170
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   171
* `UniqueConstraint`: identical to "unique=True"
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   172
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   173
* `StaticVocabularyConstraint`: identical to "vocabulary=(...)"
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   174
5220
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
   175
XXX Attribute, NOW
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: 4430
diff changeset
   176
4032
c3a018efe7c9 Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 3811
diff changeset
   177
RQL Based Constraints
c3a018efe7c9 Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 3811
diff changeset
   178
......................
c3a018efe7c9 Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 3811
diff changeset
   179
c3a018efe7c9 Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 3811
diff changeset
   180
RQL based constraints may take three arguments. The first one is the ``WHERE``
c3a018efe7c9 Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 3811
diff changeset
   181
clause of a RQL query used by the constraint. The second argument ``mainvars``
c3a018efe7c9 Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 3811
diff changeset
   182
is the ``Any`` clause of the query. By default this include `S` reserved for the
c3a018efe7c9 Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 3811
diff changeset
   183
subject of the relation and `O` for the object. Additional variables could be
c3a018efe7c9 Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 3811
diff changeset
   184
specified using ``mainvars``. The argument expects a single string with all
c3a018efe7c9 Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 3811
diff changeset
   185
variable's name separated by spaces. The last one, ``msg``, is the error message
c3a018efe7c9 Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 3811
diff changeset
   186
displayed when the constraint fails. As RQLVocabularyConstraint never fails the
c3a018efe7c9 Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 3811
diff changeset
   187
third argument is not available.
c3a018efe7c9 Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 3811
diff changeset
   188
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   189
* `RQLConstraint`: allows to specify a RQL query that has to be satisfied
4032
c3a018efe7c9 Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 3811
diff changeset
   190
  by the subject and/or the object of relation. In this query the variables
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   191
  `S` and `O` are reserved for the relation subject and object entities.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   192
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   193
* `RQLVocabularyConstraint`: similar to the previous type of constraint except
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   194
  that it does not express a "strong" constraint, which means it is only used to
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   195
  restrict the values listed in the drop-down menu of editing form, but it does
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   196
  not prevent another entity to be selected.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   197
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   198
* `RQLUniqueConstraint`: allows to the specify a RQL query that ensure that an
4032
c3a018efe7c9 Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 3811
diff changeset
   199
  attribute is unique in a specific context. The Query must **never** return more
c3a018efe7c9 Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 3811
diff changeset
   200
  than a single result to be satisfied. In this query the variables `S` is
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   201
  reserved for the relation subject entity. The other variables should be
4040
00e2f1ae625d Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 4032
diff changeset
   202
  specified with the second constructor argument (mainvars). This constraints
00e2f1ae625d Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 4032
diff changeset
   203
  should be used when UniqueConstraint doesn't fit. Here is a simple example ::
00e2f1ae625d Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 4032
diff changeset
   204
00e2f1ae625d Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 4032
diff changeset
   205
    # Check that in the same Workflow each state's name is unique.  Using
00e2f1ae625d Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 4032
diff changeset
   206
    # UniqueConstraint (or unique=True) here would prevent states in different
00e2f1ae625d Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 4032
diff changeset
   207
    # workflows to have the same name.
00e2f1ae625d Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 4032
diff changeset
   208
00e2f1ae625d Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 4032
diff changeset
   209
    # With: State S, Workflow W, String N ; S state_of W, S name N
00e2f1ae625d Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 4032
diff changeset
   210
00e2f1ae625d Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 4032
diff changeset
   211
    RQLUniqueConstraint('S name N, S state_of WF, Y state_of WF, Y name N',
00e2f1ae625d Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 4032
diff changeset
   212
                        mainvars='Y',
00e2f1ae625d Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 4032
diff changeset
   213
                        msg=_('workflow already have a state of that name'))
00e2f1ae625d Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 4032
diff changeset
   214
00e2f1ae625d Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 4032
diff changeset
   215
00e2f1ae625d Update generic RQL Based Constraints and RQLUniqueConstraint doc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 4032
diff changeset
   216
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   217
XXX note about how to add new constraint
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   218
4936
a4b772a0d801 Fixed some of the documentation warnings when building the book with sphinx.
Adrien Chauve <adrien.chauve@logilab.fr>
parents: 4744
diff changeset
   219
.. _securitymodel:
a4b772a0d801 Fixed some of the documentation warnings when building the book with sphinx.
Adrien Chauve <adrien.chauve@logilab.fr>
parents: 4744
diff changeset
   220
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   221
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   222
The security model
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   223
~~~~~~~~~~~~~~~~~~
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   224
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   225
The security model of `CubicWeb` is based on `Access Control List`.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   226
The main principles are:
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   227
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   228
* users and groups of users
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   229
* a user belongs to at least one group of user
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   230
* permissions (read, update, create, delete)
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   231
* permissions are assigned to groups (and not to users)
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   232
2175
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
   233
For *CubicWeb* in particular:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   234
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   235
* we associate rights at the entities/relations schema level
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   236
* for each entity, we distinguish four kinds of permissions: `read`,
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   237
  `add`, `update` and `delete`
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   238
* for each relation, we distinguish three kinds of permissions: `read`,
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   239
  `add` and `delete` (it is not possible to `modify` a relation)
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   240
* the default groups are: `administrators`, `users` and `guests`
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   241
* by default, users belong to the `users` group
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   242
* there is a virtual group called `owners` to which we
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   243
  can associate only `delete` and `update` permissions
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   244
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   245
  * we can not add users to the `Owners` group, they are
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   246
    implicitly added to it according to the context of the objects
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   247
    they own
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   248
  * the permissions of this group are only checked on `update`/`delete`
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   249
    actions if all the other groups the user belongs to do not provide
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   250
    those permissions
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   251
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: 4430
diff changeset
   252
Setting permissions is done with the attribute `__permissions__` of entities and
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   253
relation types. The value of this attribute is a dictionary where the keys are the access types
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   254
(action), and the values are the authorized groups or expressions.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   255
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   256
For an entity type, the possible actions are `read`, `add`, `update` and
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   257
`delete`.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   258
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   259
For a relation type, the possible actions are `read`, `add`, and `delete`.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   260
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   261
For each access type, a tuple indicates the name of the authorized groups and/or
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   262
one or multiple RQL expressions to satisfy to grant access. The access is
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   263
provided if the user is in one of the listed groups or if one of the RQL condition
4452
5d6dec2c4650 [doc] small fixes on security part
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3811
diff changeset
   264
is satisfied.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   265
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   266
The standard user groups
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   267
````````````````````````
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   268
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   269
* `guests`
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   270
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   271
* `users`
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   272
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   273
* `managers`
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   274
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   275
* `owners`: virtual group corresponding to the entity's owner.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   276
  This can only be used for the actions `update` and `delete` of an entity
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   277
  type.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   278
4744
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4464
diff changeset
   279
It is also possible to use specific groups if they are defined in the
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   280
precreate script of the cube (``migration/precreate.py``). Defining groups in
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   281
postcreate script or later makes them unavailable for security
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   282
purposes (in this case, an `sync_schema_props_perms` command has to
4744
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4464
diff changeset
   283
be issued in a CubicWeb shell).
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   284
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   285
3283
4f53eb3f1331 more doc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3144
diff changeset
   286
Use of RQL expression for write permissions
4464
437cc57f7474 fix rest syntax error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4459
diff changeset
   287
```````````````````````````````````````````
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
   288
It is possible to define RQL expression to provide update permission
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   289
(`add`, `delete` and `update`) on relation and entity types.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   290
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   291
RQL expression for entity type permission:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   292
3811
3726e921f537 small fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3581
diff changeset
   293
* you have to use the class `ERQLExpression`
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   294
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   295
* the used expression corresponds to the WHERE statement of an RQL query
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   296
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   297
* in this expression, the variables `X` and `U` are pre-defined references
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   298
  respectively on the current entity (on which the action is verified) and
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   299
  on the user who send the request
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   300
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
   301
* it is possible to use, in this expression, a special relation
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
   302
  "has_<ACTION>_permission" where the subject is the user and the
4452
5d6dec2c4650 [doc] small fixes on security part
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3811
diff changeset
   303
  object is any variable, meaning that the user needs to have
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   304
  permission to execute the action <ACTION> on the entities related
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
   305
  to this variable
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   306
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
   307
For RQL expressions on a relation type, the principles are the same except
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   308
for the following:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   309
3811
3726e921f537 small fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3581
diff changeset
   310
* you have to use the class `RRQLExpression` in the case of a non-final relation
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   311
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   312
* in the expression, the variables `S`, `O` and `U` are pre-defined references
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   313
  to respectively the subject and the object of the current relation (on
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   314
  which the action is being verified) and the user who executed the query
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   315
3811
3726e921f537 small fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3581
diff changeset
   316
* we can also define rights over attributes of an entity (non-final relation),
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   317
  knowing that:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   318
3811
3726e921f537 small fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3581
diff changeset
   319
  - to define RQL expression, we have to use the class `ERQLExpression`
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   320
    in which `X` represents the entity the attribute belongs to
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   321
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   322
  - the permissions `add` and `delete` are equivalent. Only `add`/`read`
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   323
    are actually taken in consideration.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   324
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   325
:Note on the use of RQL expression for `add` permission:
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   326
4452
5d6dec2c4650 [doc] small fixes on security part
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3811
diff changeset
   327
  Potentially, the use of an RQL expression to add an entity or a
5d6dec2c4650 [doc] small fixes on security part
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3811
diff changeset
   328
  relation can cause problems for the user interface, because if the
5d6dec2c4650 [doc] small fixes on security part
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3811
diff changeset
   329
  expression uses the entity or the relation to create, then we are
5d6dec2c4650 [doc] small fixes on security part
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3811
diff changeset
   330
  not able to verify the permissions before we actually add the entity
5d6dec2c4650 [doc] small fixes on security part
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3811
diff changeset
   331
  (please note that this is not a problem for the RQL server at all,
5d6dec2c4650 [doc] small fixes on security part
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3811
diff changeset
   332
  because the permissions checks are done after the creation). In such
5d6dec2c4650 [doc] small fixes on security part
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3811
diff changeset
   333
  case, the permission check methods (CubicWebEntitySchema.check_perm
5d6dec2c4650 [doc] small fixes on security part
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3811
diff changeset
   334
  and has_perm) can indicate that the user is not allowed to create
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
   335
  this entity but can obtain the permission.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   336
  To compensate this problem, it is usually necessary, for such case,
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   337
  to use an action that reflects the schema permissions but which enables
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   338
  to check properly the permissions so that it would show up if necessary.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   339
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
   340
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   341
Use of RQL expression for reading rights
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   342
````````````````````````````````````````
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   343
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   344
The principles are the same but with the following restrictions:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   345
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   346
* we can not use `RRQLExpression` on relation types for reading
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   347
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   348
* special relations "has_<ACTION>_permission" can not be used
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   349
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   350
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   351
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   352
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   353
Defining your schema using yams
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   354
-------------------------------
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   355
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   356
Entity type definition
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   357
~~~~~~~~~~~~~~~~~~~~~~
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   358
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   359
An entity type is defined by a Python class which inherits from
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   360
:class:`yams.buildobjs.EntityType`.  The class definition contains the
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   361
description of attributes and relations for the defined entity type.
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   362
The class name corresponds to the entity type name. It is expected to
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   363
be defined in the module ``mycube.schema``.
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   364
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   365
:Note on schema definition:
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   366
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   367
 The code in ``mycube.schema`` is not meant to be executed. The class
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   368
 EntityType mentioned above is different from the EntitySchema class
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   369
 described in the previous chapter. EntityType is a helper class to
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   370
 make Entity definition easier. Yams will process EntityType classes
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   371
 and create EntitySchema instances from these class definitions. Similar
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   372
 manipulation happen for relations.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   373
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: 4430
diff changeset
   374
When defining a schema using python files, you may use the following shortcuts:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   375
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   376
- `required`: boolean indicating if the attribute is required, ed subject cardinality is '1'
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: 4430
diff changeset
   377
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   378
- `vocabulary`: specify static possible values of an attribute
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: 4430
diff changeset
   379
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   380
- `maxsize`: integer providing the maximum size of a string (no limit by default)
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: 4430
diff changeset
   381
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: 4430
diff changeset
   382
For example:
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: 4430
diff changeset
   383
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: 4430
diff changeset
   384
.. sourcecode:: python
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   385
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   386
  class Person(EntityType):
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   387
    """A person with the properties and the relations necessary for my
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   388
    application"""
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   389
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   390
    last_name = String(required=True, fulltextindexed=True)
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   391
    first_name = String(required=True, fulltextindexed=True)
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   392
    title = String(vocabulary=('Mr', 'Mrs', 'Miss'))
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   393
    date_of_birth = Date()
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   394
    works_for = SubjectRelation('Company', cardinality='?*')
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   395
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   396
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   397
The entity described above defines three attributes of type String,
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   398
last_name, first_name and title, an attribute of type Date for the date of
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   399
birth and a relation that connects a `Person` to another entity of type
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   400
`Company` through the semantic `works_for`.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   401
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   402
:Naming convention:
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   403
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   404
 Entity class names must start with an uppercase letter. The common
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   405
 usage is to use ``CamelCase`` names.
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   406
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   407
 Attribute and relation names must start with a lowercase letter. The
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   408
 common usage is to use ``underscore_separated_words``. Attribute and
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   409
 relation names starting with a single underscore are permitted, to
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   410
 denote a somewhat "protected" or "private" attribute.
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   411
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   412
 In any case, identifiers starting with "CW" or "cw" are reserved for
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   413
 internal use by the framework.
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   414
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   415
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   416
The name of the Python attribute corresponds to the name of the attribute
2175
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
   417
or the relation in *CubicWeb* application.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   418
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   419
An attribute is defined in the schema as follows::
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
   420
4449
0411dca43e05 fix bad rest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4446
diff changeset
   421
    attr_name = attr_type(properties)
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   422
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   423
where `attr_type` is one of the type listed above and `properties` is
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   424
a list of the attribute needs to satisfy (see `Properties`_
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
   425
for more details).
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   426
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   427
* it is possible to use the attribute `meta` to flag an entity type as a `meta`
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   428
  (e.g. used to describe/categorize other entities)
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   429
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   430
.. XXX the paragraph below needs clarification and / or moving out in
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   431
.. another place
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   432
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   433
*Note*: if you end up with an `if` in the definition of your entity, this probably
4430
0b6a069eb29e le patch added_tips a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4040
diff changeset
   434
means that you need two separate entities that implement the `ITree` interface and
0b6a069eb29e le patch added_tips a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4040
diff changeset
   435
get the result from `.children()` which ever entity is concerned.
0b6a069eb29e le patch added_tips a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4040
diff changeset
   436
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   437
Inheritance
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   438
```````````
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   439
XXX feed me
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   440
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   441
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   442
Definition of relations
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   443
~~~~~~~~~~~~~~~~~~~~~~~
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   444
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   445
XXX add note about defining relation type / definition
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   446
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   447
A relation is defined by a Python class heriting `RelationType`. The name
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   448
of the class corresponds to the name of the type. The class then contains
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
   449
a description of the properties of this type of relation, and could as well
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   450
contain a string for the subject and a string for the object. This allows to create
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
   451
new definition of associated relations, (so that the class can have the
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   452
definition properties from the relation) for example ::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   453
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   454
  class locked_by(RelationType):
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   455
    """relation on all entities indicating that they are locked"""
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   456
    inlined = True
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   457
    cardinality = '?*'
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   458
    subject = '*'
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   459
    object = 'CWUser'
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   460
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   461
If provided, the `subject` and `object` attributes denote the subject
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   462
and object of the various relation definitions related to the relation
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   463
type. Allowed values for these attributes are:
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   464
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   465
* a string corresponding to an entity type
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   466
* a tuple of string corresponding to multiple entity types
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   467
* special string such as follows:
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   468
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   469
  - "**": all types of entities
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   470
  - "*": all types of non-meta entities
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   471
  - "@": all types of meta entities but not system entities (e.g. used for
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   472
    the basic schema description)
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   473
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   474
When a relation is not inlined and not symmetrical, and it does not require
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   475
specific permissions, it can be defined using a `SubjectRelation`
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   476
attribute in the EntityType class. The first argument of `SubjectRelation` gives
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   477
the entity type for the object of the relation.
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   478
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   479
:Naming convention:
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   480
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   481
 Although this way of defining relations uses a Python class, the
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   482
 naming convention defined earlier prevails over the PEP8 conventions
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   483
 used in the framework: relation type class names use
5220
42f854b6083d [doc/book] complete chapter on hooks & ops
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5145
diff changeset
   484
 ``underscore_separated_words``.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   485
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   486
:Historical note:
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   487
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   488
   It has been historically possible to use `ObjectRelation` which
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   489
   defines a relation in the opposite direction. This feature is soon to be
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   490
   deprecated and therefore should not be used in newly written code.
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   491
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   492
:Future deprecation note:
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   493
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   494
  In an even more remote future, it is quite possible that the
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   495
  SubjectRelation shortcut will become deprecated, in favor of the
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   496
  RelationType declaration which offers some advantages in the context
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   497
  of reusable cubes.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   498
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   499
Definition of permissions
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   500
~~~~~~~~~~~~~~~~~~~~~~~~~~
4452
5d6dec2c4650 [doc] small fixes on security part
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3811
diff changeset
   501
The entity type `CWPermission` from the standard library
5d6dec2c4650 [doc] small fixes on security part
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3811
diff changeset
   502
allows to build very complex and dynamic security architectures. The schema of
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   503
this entity type is as follow:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   504
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: 4430
diff changeset
   505
.. sourcecode:: python
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   506
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: 4430
diff changeset
   507
    class CWPermission(EntityType):
4459
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   508
        """entity type that may be used to construct some advanced security configuration
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   509
        """
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   510
        name = String(required=True, indexed=True, internationalizable=True, maxsize=100)
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   511
        require_group = SubjectRelation('CWGroup', cardinality='+*',
4459
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   512
                                        description=_('groups to which the permission is granted'))
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   513
        require_state = SubjectRelation('State',
3144
a5deac822a13 Bugfix: message was not written in english
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2476
diff changeset
   514
                                        description=_("entity's state in which the permission is applicable"))
4459
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   515
        # can be used on any entity
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   516
        require_permission = ObjectRelation('**', cardinality='*1', composite='subject',
4459
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   517
                                            description=_("link a permission to the entity. This "
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   518
                                                          "permission should be used in the security "
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   519
                                                          "definition of the entity's type to be useful."))
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   520
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   521
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: 4430
diff changeset
   522
Example of configuration:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   523
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: 4430
diff changeset
   524
.. sourcecode:: python
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   525
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   526
    class Version(EntityType):
4459
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   527
        """a version is defining the content of a particular project's release"""
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   528
4459
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   529
        __permissions__ = {'read':   ('managers', 'users', 'guests',),
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   530
                           'update': ('managers', 'logilab', 'owners',),
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   531
                           'delete': ('managers', ),
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   532
                           'add':    ('managers', 'logilab',
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   533
                                       ERQLExpression('X version_of PROJ, U in_group G,'
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   534
                                                 'PROJ require_permission P, P name "add_version",'
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   535
                                                 'P require_group G'),)}
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   536
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   537
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   538
    class version_of(RelationType):
4459
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   539
        """link a version to its project. A version is necessarily linked to one and only one project.
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   540
        """
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   541
        __permissions__ = {'read':   ('managers', 'users', 'guests',),
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   542
                           'delete': ('managers', ),
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   543
                           'add':    ('managers', 'logilab',
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   544
                                  RRQLExpression('O require_permission P, P name "add_version",'
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   545
                                                 'U in_group G, P require_group G'),)
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   546
                       }
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   547
        inlined = True
f628abfb3a6c backport stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4449 4452
diff changeset
   548
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   549
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   550
This configuration indicates that an entity `CWPermission` named
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   551
"add_version" can be associated to a project and provides rights to create
5145
bfa4d775219f added information about the naming conventions in schema.py
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 4936
diff changeset
   552
new versions on this project to specific groups. It is important to notice that:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   553
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   554
* in such case, we have to protect both the entity type "Version" and the relation
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   555
  associating a version to a project ("version_of")
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   556
3283
4f53eb3f1331 more doc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3144
diff changeset
   557
* because of the genericity of the entity type `CWPermission`, we have to execute
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   558
  a unification with the groups and/or the states if necessary in the expression
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   559
  ("U in_group G, P require_group G" in the above example)