doc/book/en/B0012-schema-definition.en.txt
author Graziella Toutoungis <graziella.toutoungis@logilab.fr>
Tue, 31 Mar 2009 17:09:38 +0200
changeset 1194 e224f064a268
parent 1164 88834894d2d7
child 1205 79d33f7db590
permissions -rw-r--r--
optimize this code part
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     1
.. -*- coding: utf-8 -*-
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     2
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
     3
Entity type definition
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
     4
----------------------
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     5
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
     6
An entity type is defined by a Python class which inherits from `EntityType`.
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
     7
The class definition contains the description of attributes and relations
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
     8
for the defined entity type.
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
     9
The class name corresponds to the entity type name.
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    10
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    11
For example ::
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    12
1159
16a426d214ae use english example names
Emile Anclin <emile.anclin@logilab.fr>
parents: 301
diff changeset
    13
  class Person(EntityType):
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    14
    """A person with the properties and the relations necessary for my
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    15
    application"""
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    16
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    17
    last_name = String(required=True, fulltextindexed=True)
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    18
    first_name = String(required=True, fulltextindexed=True)
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    19
    title = String(vocabulary=('Mr', 'Mrs', 'Miss'))
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    20
    date_of_birth = Date()
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    21
    works_for = SubjectRelation('Company', cardinality='?*')
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    22
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    23
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    24
* the name of the Python attribute corresponds to the name of the attribute
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    25
  or the relation in `CubicWeb` application.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    26
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    27
* all `CubicWeb` built-in types are available : `String`, `Int`, `Float`,
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    28
  `Boolean`, `Date`, `Datetime`, `Time`, `Byte`; they are and implicitely
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    29
  imported (as well as the special the function "_").
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    30
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    31
* each entity type has at least the following meta-relations :
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    32
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    33
  - `eid` (`Int`)
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    34
  
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    35
  - `creation_date` (`Datetime`)
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    36
  
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    37
  - `modification_date` (`Datetime`)
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    38
  
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    39
  - `created_by` (`EUser`) (which user created the entity)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    40
  
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    41
  - `owned_by` (`EUser`) (to whom the entity belongs; by default the 
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    42
     creator but not necessary, and it could have multiple owners)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    43
     
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    44
  - `is` (`EEType`)
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    45
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    46
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    47
* relations can be defined by using `ObjectRelation` or `SubjectRelation`.
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    48
  The first argument of `SubjectRelation` or `ObjectRelation` gives respectively
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    49
  the object/subject entity type of the relation. This could be :  
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    50
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    51
  * a string corresponding to an entity type
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    52
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    53
  * a tuple of string corresponding to multiple entity types
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    54
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    55
  * special string such as follows :
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    56
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    57
    - "**" : all types of entities
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    58
    - "*" : all types of non-meta entities 
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    59
    - "@" : all types of meta entities but not system entities (e.g. used for
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    60
      the basic schema description)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    61
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    62
* it is possible to use the attribute `meta` to flag an entity type as a `meta`
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    63
  (e.g. used to describe/categorize other entities)
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    64
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    65
* optional properties for attributes and relations : 
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    66
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    67
  - `description` : a string describing an attribute or a relation. By default
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    68
    this string will be used in the editing form of the entity, which means
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    69
    that it is supposed to help the end-user and should be flagged by the
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    70
    function `_` to be properly internationalized.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    71
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    72
  - `constraints` : a list of conditions/constraints that the relation has to
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    73
    satisfy (c.f. `Contraints`_)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    74
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    75
  - `cardinality` : a two character string which specify the cardinality of the
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    76
    relation. The first character defines the cardinality of the relation on
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    77
    the subject, and the second on the object. When a relation can have 
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    78
    multiple subjects or objects, the cardinality applies to all,
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    79
    not on a one-to-one basis (so it must be consistent...). The possible
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    80
    values are inspired from regular expression syntax :
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    81
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    82
    * `1`: 1..1
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    83
    * `?`: 0..1
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    84
    * `+`: 1..n
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    85
    * `*`: 0..n
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    86
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    87
  - `meta` : boolean indicating that the relation is a meta-relation (false by
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    88
    default)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    89
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    90
* optional properties for attributes : 
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    91
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    92
  - `required` : boolean indicating if the attribute is required (false by default)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    93
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    94
  - `unique` : boolean indicating if the value of the attribute has to be unique
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    95
    or not within all entities of the same type (false by default)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    96
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    97
  - `indexed` : boolean indicating if an index needs to be created for this 
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    98
    attribute in the database (false by default). This is usefull only if
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    99
    you know that you will have to run numerous searches on the value of this
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   100
    attribute.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   101
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   102
  - `default` : default value of the attribute. In case of date types, the values
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
   103
    which could be used correspond to the RQL keywords `TODAY` and `NOW`.
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   104
  
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   105
  - `vocabulary` : specify static possible values of an attribute
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   106
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
   107
* optional properties of type `String` : 
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   108
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   109
  - `fulltextindexed` : boolean indicating if the attribute is part of
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   110
    the full text index (false by default) (*applicable on the type `Byte`
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   111
    as well*)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   112
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   113
  - `internationalizable` : boolean indicating if the value of the attribute
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   114
    is internationalizable (false by default)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   115
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   116
  - `maxsize` : integer providing the maximum size of the string (no limit by default)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   117
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
   118
* optional properties for relations : 
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   119
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   120
  - `composite` : string indicating that the subject (composite == 'subject')
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   121
    is composed of the objects of the relations. For the opposite case (when
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
   122
    the object is composed of the subjects of the relation), we just set 
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
   123
    'object' as value. The composition implies that when the relation
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   124
    is deleted (so when the composite is deleted), the composed are also deleted.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   125
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   126
Contraints
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   127
``````````
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
   128
By default, the available constraint types are :
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   129
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   130
* `SizeConstraint` : allows to specify a minimum and/or maximum size on
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   131
  string (generic case of `maxsize`)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   132
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   133
* `BoundConstraint` : allows to specify a minimum and/or maximum value on 
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   134
  numeric types
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   135
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   136
* `UniqueConstraint` : identical to "unique=True"
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   137
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   138
* `StaticVocabularyConstraint` : identical to "vocabulary=(...)"
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   139
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
   140
* `RQLConstraint` : allows to specify a RQL query that has to be satisfied
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   141
  by the subject and/or the object of the relation. In this query the variables
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   142
  `S` and `O` are reserved for the entities subject and object of the 
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   143
  relation.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   144
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   145
* `RQLVocabularyConstraint` : similar to the previous type of constraint except
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   146
  that it does not express a "strong" constraint, which means it is only used to
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   147
  restrict the values listed in the drop-down menu of editing form, but it does
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
   148
  not prevent another entity to be selected.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   149
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   150
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   151
Relation definition
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   152
-------------------
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   153
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   154
XXX add note about defining relation type / definition
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   155
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   156
A relation is defined by a Python class heriting `RelationType`. The name
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   157
of the class corresponds to the name of the type. The class then contains
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   158
a description of the properties of this type of relation, and could as well 
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
   159
contain a string for the subject and a string for the object. This allows to create
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   160
new definition of associated relations, (so that the class can have the 
229
767ff7f5d5a7 [doc] Replace all : s/by example/for example/
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 171
diff changeset
   161
definition properties from the relation) for example ::
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   162
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   163
  class locked_by(RelationType):
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   164
    """relation on all entities indicating that they are locked"""
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   165
    inlined = True
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   166
    cardinality = '?*'
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   167
    subject = '*'
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   168
    object = 'EUser'
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   169
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   170
In addition to the permissions, the properties of the relation types
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   171
(shared also by all definition of relation of this type) are :
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   172
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   173
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   174
* `inlined` : boolean handling the physical optimization for archiving
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   175
  the relation in the subject entity table, instead of creating a specific
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   176
  table for the relation. This applies to the relation when the cardinality
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   177
  of subject->relation->object is 0..1 (`?`) or 1..1 (`1`)
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   178
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
   179
* `symmetric` : boolean indicating that the relation is symmetrical, which
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   180
  means `X relation Y` implies `Y relation X`
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   181
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   182
In the case of simultaneous relations definitions, `subject` and `object`
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   183
can both be equal to the value of the first argument of `SubjectRelation`
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   184
and `ObjectRelation`.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   185
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
   186
When a relation is not inlined and not symmetrical, and it does not require
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   187
specific permissions, its definition (by using `SubjectRelation` and
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   188
`ObjectRelation`) is all we need.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   189
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   190
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   191
The security model
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   192
------------------
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   193
128
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   194
The security model of `cubicWeb` is based on `Access Control List`. 
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   195
The main principles are:
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   196
128
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   197
* users and groups of users
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   198
* a user belongs to at least one group of user
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   199
* permissions (read, update, create, delete)
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   200
* permissions are assigned to groups (and not to users)
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   201
128
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   202
For `CubicWeb` in particular:
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   203
128
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   204
* we associate rights at the enttities/relations schema level
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   205
* for each entity, we distinguish four kind of permissions: read,
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   206
  add, update and delete
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   207
* for each relation, we distinguish three king of permissions: read,
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   208
  add and delete (we can not modify a relation)
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   209
* the basic groups are: Administrators, Users and Guests
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   210
* by default, users belongs to the group Users
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   211
* there is a virtual group called `Owners users` to which we
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   212
  can associate only deletion and update permissions
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   213
* we can not add users to the `Owners users` group, they are
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   214
  implicetely added to it according to the context of the objects
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   215
  they own
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   216
* the permissions of this group are only be checked on update/deletion
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   217
  actions if all the other groups the user belongs does not provide
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   218
  those permissions
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   219
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   220
  
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   221
Permissions definition
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   222
``````````````````````
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   223
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   224
Define permissions is set through to the attribute `permissions` of entities and
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   225
relations types. It defines a dictionnary where the keys are the access types
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   226
(action), and the values are the authorized groups or expressions.
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   227
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   228
For an entity type, the possible actions are `read`, `add`, `update` and
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   229
`delete`.
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   230
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   231
For a relation type, the possible actions are `read`, `add`, and `delete`.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   232
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   233
For each access type, a tuple indicates the name of the authorized groups and/or
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   234
one or multiple RQL expressions to satisfy to grant access. The access is
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   235
provided once the user is in the listed groups or one of the RQL condition is
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   236
satisfied.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   237
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   238
The standard groups are :
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   239
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   240
* `guests`
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   241
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   242
* `users`
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   243
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   244
* `managers`
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   245
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   246
* `owners` : virtual group corresponding to the entity's owner.
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   247
  This can only be used for the actions `update` and `delete` of an entity
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   248
  type.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   249
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   250
It is also possible to use specific groups if they are defined in the precreate 
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   251
of the cube (``migration/precreate.py``).
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   252
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   253
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   254
Use of RQL expression for writing rights
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   255
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   256
It is possible to define RQL expression to provide update permission 
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   257
(`add`, `delete` and `update`) on relation and entity types.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   258
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   259
RQL expression for entity type permission :
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   260
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   261
* you have to use the class `ERQLExpression`
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   262
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   263
* the used expression corresponds to the WHERE statement of an RQL query
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   264
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   265
* in this expression, the variables X and U are pre-defined references
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   266
  respectively on the current entity (on which the action is verified) and
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   267
  on the user who send the request
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   268
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   269
* it is possible to use, in this expression, a special relation 
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   270
  "has_<ACTION>_permission" where the subject is the user and the 
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   271
  object is a any variable, meaning that the user needs to have
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   272
  permission to execute the action <ACTION> on the entities related
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   273
  to this variable 
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   274
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   275
For RQL expressions on a relation type, the principles are the same except 
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   276
for the following :
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   277
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   278
* you have to use the class `RQLExpression` in the case of a non-final relation
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   279
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   280
* in the expression, the variables S, O and U are pre-defined references
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   281
  to respectively the subject and the object of the current relation (on
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   282
  which the action is being verified) and the user who executed the query
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   283
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   284
* we can also defined rights on attributes of an entity (non-final relation),
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   285
  knowing that : 
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   286
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   287
  - to defines RQL expression, we have to use the class `ERQLExpression`
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   288
    in which X represents the entity the attribute belongs to
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   289
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   290
  - the permissions `add` and `delete` are equivalent. Only `add`/`read`
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   291
    are actually taken in consideration.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   292
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   293
In addition to that the entity type `EPermission` from the standard library
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   294
allow to build very complex and dynamic security architecture. The schema of
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   295
this entity type is as follow : ::
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   296
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   297
    class EPermission(MetaEntityType):
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   298
	"""entity type that may be used to construct some advanced security configuration
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   299
	"""
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   300
	name = String(required=True, indexed=True, internationalizable=True, maxsize=100)
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   301
	require_group = SubjectRelation('EGroup', cardinality='+*',
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   302
					description=_('groups to which the permission is granted'))
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   303
	require_state = SubjectRelation('State',
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   304
				    description=_("entity'state in which the permission is applyable"))
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   305
	# can be used on any entity
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   306
	require_permission = ObjectRelation('**', cardinality='*1', composite='subject',
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   307
					    description=_("link a permission to the entity. This "
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   308
							  "permission should be used in the security "
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   309
							  "definition of the entity's type to be useful."))
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   310
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   311
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   312
Example of configuration ::
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   313
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   314
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   315
    ...
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   316
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   317
    class Version(EntityType):
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   318
	"""a version is defining the content of a particular project's release"""
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   319
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   320
	permissions = {'read':   ('managers', 'users', 'guests',),
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   321
		       'update': ('managers', 'logilab', 'owners',),
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   322
		       'delete': ('managers', ),
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   323
		       'add':    ('managers', 'logilab',
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   324
				  ERQLExpression('X version_of PROJ, U in_group G,'
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   325
						 'PROJ require_permission P, P name "add_version",'
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   326
						 'P require_group G'),)}
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   327
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   328
    ...
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   329
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   330
    class version_of(RelationType):
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   331
	"""link a version to its project. A version is necessarily linked to one and only one project.
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   332
	"""
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   333
	permissions = {'read':   ('managers', 'users', 'guests',),
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   334
		       'delete': ('managers', ),
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   335
		       'add':    ('managers', 'logilab',
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   336
				  RRQLExpression('O require_permission P, P name "add_version",'
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   337
						 'U in_group G, P require_group G'),)
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   338
		       }
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   339
	inlined = True
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   340
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   341
This configuration indicates that an entity `EPermission` named
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   342
"add_version" can be associated to a project and provides rights to create
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   343
new versions on this project to specific groups. It is important to notice that :
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   344
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   345
* in such case, we have to protect both the entity type "Version" and the relation
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   346
  associating a version to a project ("version_of")
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   347
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   348
* because of the genricity of the entity type `EPermission`, we have to execute
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   349
  a unification with the groups and/or the states if necessary in the expression
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   350
  ("U in_group G, P require_group G" in the above example)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   351
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   352
Use of RQL expression for reading rights
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   353
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   354
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   355
The principles are the same but with the following restrictions :
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   356
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   357
* we can not use `RRQLExpression` on relation types for reading
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   358
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   359
* special relations "has_<ACTION>_permission" can not be used
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   360
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   361
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   362
Note on the use of RQL expression for `add` permission
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   363
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   364
Potentially, the use of an RQL expression to add an entity or a relation
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   365
can cause problems for the user interface, because if the expression uses
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   366
the entity or the relation to create, then we are not able to verify the 
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   367
permissions before we actually add the entity (please note that this is
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   368
not a problem for the RQL server at all, because the permissions checks are
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   369
done after the creation). In such case, the permission check methods 
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   370
(check_perm, has_perm) can indicate that the user is not allowed to create 
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   371
this entity but can obtain the permission. 
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   372
To compensate this problem, it is usually necessary, for such case,
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   373
to use an action that reflects the schema permissions but which enables
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   374
to check properly the permissions so that it would show up if necessary.
171
c7d6a465b951 updates done to documentation after following instructions for a new cube
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 128
diff changeset
   375
c7d6a465b951 updates done to documentation after following instructions for a new cube
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 128
diff changeset
   376
c7d6a465b951 updates done to documentation after following instructions for a new cube
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 128
diff changeset
   377
Updating your application with your new schema
c7d6a465b951 updates done to documentation after following instructions for a new cube
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 128
diff changeset
   378
``````````````````````````````````````````````
c7d6a465b951 updates done to documentation after following instructions for a new cube
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 128
diff changeset
   379
1164
88834894d2d7 explain cubicweb-ctl shell
Emile Anclin <emile.anclin@logilab.fr>
parents: 1163
diff changeset
   380
If you modified your schema, the update is not automatic; this is 
88834894d2d7 explain cubicweb-ctl shell
Emile Anclin <emile.anclin@logilab.fr>
parents: 1163
diff changeset
   381
indeed in general not a good idea.
88834894d2d7 explain cubicweb-ctl shell
Emile Anclin <emile.anclin@logilab.fr>
parents: 1163
diff changeset
   382
Instead, we call a shell on  your application, which is a 
88834894d2d7 explain cubicweb-ctl shell
Emile Anclin <emile.anclin@logilab.fr>
parents: 1163
diff changeset
   383
an interactive python shell, with an appropriate
88834894d2d7 explain cubicweb-ctl shell
Emile Anclin <emile.anclin@logilab.fr>
parents: 1163
diff changeset
   384
cubicweb environment ::
171
c7d6a465b951 updates done to documentation after following instructions for a new cube
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 128
diff changeset
   385
1159
16a426d214ae use english example names
Emile Anclin <emile.anclin@logilab.fr>
parents: 301
diff changeset
   386
   cubicweb-ctl shell myinstance
171
c7d6a465b951 updates done to documentation after following instructions for a new cube
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 128
diff changeset
   387
c7d6a465b951 updates done to documentation after following instructions for a new cube
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 128
diff changeset
   388
and type ::
c7d6a465b951 updates done to documentation after following instructions for a new cube
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 128
diff changeset
   389
1159
16a426d214ae use english example names
Emile Anclin <emile.anclin@logilab.fr>
parents: 301
diff changeset
   390
   add_entity_type('Person')
171
c7d6a465b951 updates done to documentation after following instructions for a new cube
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 128
diff changeset
   391
c7d6a465b951 updates done to documentation after following instructions for a new cube
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 128
diff changeset
   392
And restart your application!