doc/book/en/B0012-schema-definition.en.txt
author Sandrine Ribeau <sandrine.ribeau@logilab.fr>
Wed, 22 Apr 2009 14:14:11 -0700
changeset 1439 e1cfa73f6e78
parent 1352 9fae16f3e068
child 1442 db4e2508082b
child 1588 79755c89b4f3
permissions -rw-r--r--
[doc] Add little 'wrapping' in tutorial.
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.
1352
9fae16f3e068 [doc] Explicitely name the module in which we define schema to distinguish it from entities.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 1222
diff changeset
     9
The class name corresponds to the entity type name. It is exepected to be
9fae16f3e068 [doc] Explicitely name the module in which we define schema to distinguish it from entities.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 1222
diff changeset
    10
defined in the module ``mycube.schema``.
9fae16f3e068 [doc] Explicitely name the module in which we define schema to distinguish it from entities.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 1222
diff changeset
    11
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    12
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    13
For example ::
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    14
1159
16a426d214ae use english example names
Emile Anclin <emile.anclin@logilab.fr>
parents: 301
diff changeset
    15
  class Person(EntityType):
301
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 292
diff changeset
    16
    """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
    17
    application"""
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    18
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    19
    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
    20
    first_name = String(required=True, fulltextindexed=True)
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    21
    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
    22
    date_of_birth = Date()
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    23
    works_for = SubjectRelation('Company', cardinality='?*')
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    24
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    25
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    26
* 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
    27
  or the relation in `CubicWeb` application.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    28
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    29
* all `CubicWeb` built-in types are available : `String`, `Int`, `Float`,
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    30
  `Boolean`, `Date`, `Datetime`, `Time`, `Byte`; they are and implicitely
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    31
  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
    32
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    33
* 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
    34
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    35
  - `eid` (`Int`)
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
  - `creation_date` (`Datetime`)
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    38
  
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    39
  - `modification_date` (`Datetime`)
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    40
  
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    41
  - `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
    42
  
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    43
  - `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
    44
     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
    45
     
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    46
  - `is` (`EEType`)
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    47
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    48
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    49
* relations can be defined by using `ObjectRelation` or `SubjectRelation`.
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    50
  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
    51
  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
    52
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    53
  * 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
    54
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    55
  * 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
    56
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    57
  * special string such as follows :
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    58
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    59
    - "**" : all types of entities
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    60
    - "*" : all types of non-meta entities 
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    61
    - "@" : 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
    62
      the basic schema description)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    63
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    64
* 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
    65
  (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
    66
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    67
* optional properties for attributes and relations : 
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    68
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    69
  - `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
    70
    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
    71
    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
    72
    function `_` to be properly internationalized.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    73
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    74
  - `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
    75
    satisfy (c.f. `Contraints`_)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    76
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    77
  - `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
    78
    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
    79
    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
    80
    multiple subjects or objects, the cardinality applies to all,
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    81
    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
    82
    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
    83
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    84
    * `1`: 1..1
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    85
    * `?`: 0..1
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    86
    * `+`: 1..n
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    87
    * `*`: 0..n
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    88
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    89
  - `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
    90
    default)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    91
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
    92
* optional properties for attributes : 
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
  - `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
    95
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    96
  - `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
    97
    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
    98
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    99
  - `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
   100
    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
   101
    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
   102
    attribute.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   103
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   104
  - `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
   105
    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
   106
  
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   107
  - `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
   108
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
   109
* optional properties of type `String` : 
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   110
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   111
  - `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
   112
    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
   113
    as well*)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   114
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   115
  - `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
   116
    is internationalizable (false by default)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   117
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   118
  - `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
   119
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
   120
* optional properties for relations : 
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   121
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   122
  - `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
   123
    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
   124
    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
   125
    '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
   126
    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
   127
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   128
Contraints
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   129
``````````
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
   130
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
   131
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   132
* `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
   133
  string (generic case of `maxsize`)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   134
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   135
* `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
   136
  numeric types
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
* `UniqueConstraint` : identical to "unique=True"
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   139
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   140
* `StaticVocabularyConstraint` : identical to "vocabulary=(...)"
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   141
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
   142
* `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
   143
  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
   144
  `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
   145
  relation.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   146
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   147
* `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
   148
  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
   149
  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
   150
  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
   151
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   152
1205
79d33f7db590 [doc] some more small improvements
Emile Anclin <emile.anclin@logilab.fr>
parents: 1164
diff changeset
   153
Definition of relations
79d33f7db590 [doc] some more small improvements
Emile Anclin <emile.anclin@logilab.fr>
parents: 1164
diff changeset
   154
-----------------------
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   155
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   156
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
   157
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   158
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
   159
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
   160
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
   161
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
   162
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
   163
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
   164
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   165
  class locked_by(RelationType):
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   166
    """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
   167
    inlined = True
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   168
    cardinality = '?*'
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   169
    subject = '*'
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   170
    object = 'EUser'
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   171
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   172
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
   173
(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
   174
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   175
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   176
* `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
   177
  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
   178
  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
   179
  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
   180
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
   181
* `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
   182
  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
   183
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   184
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
   185
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
   186
and `ObjectRelation`.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   187
1163
232aef110a0a doc improvements; typos
Emile Anclin <emile.anclin@logilab.fr>
parents: 1159
diff changeset
   188
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
   189
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
   190
`ObjectRelation`) is all we need.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   191
122
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
The security model
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   194
------------------
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   195
128
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   196
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
   197
The main principles are:
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   198
128
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   199
* users and groups of users
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   200
* 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
   201
* permissions (read, update, create, delete)
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   202
* 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
   203
128
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   204
For `CubicWeb` in particular:
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   205
128
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   206
* 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
   207
* 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
   208
  add, update and delete
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   209
* 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
   210
  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
   211
* 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
   212
* 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
   213
* 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
   214
  can associate only deletion and update permissions
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   215
* 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
   216
  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
   217
  they own
40edb9347b1b [doc] Translation of security model section.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   218
* 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
   219
  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
   220
  those permissions
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   221
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
Permissions definition
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   224
``````````````````````
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   225
1205
79d33f7db590 [doc] some more small improvements
Emile Anclin <emile.anclin@logilab.fr>
parents: 1164
diff changeset
   226
Setting permissions is done with the attribute `permissions` of entities and
1222
0d5035525a23 [doc] spelling : dictionary
Emile Anclin <emile.anclin@logilab.fr>
parents: 1205
diff changeset
   227
relation types. It defines a dictionary where the keys are the access types
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   228
(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
   229
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   230
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
   231
`delete`.
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 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
   234
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   235
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
   236
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
   237
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
   238
satisfied.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   239
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   240
The standard groups are :
93
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
* `guests`
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
* `users`
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   245
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   246
* `managers`
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   247
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   248
* `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
   249
  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
   250
  type.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   251
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   252
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
   253
of the cube (``migration/precreate.py``).
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   254
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   255
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   256
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
   257
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   258
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
   259
(`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
   260
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   261
RQL expression for entity type permission :
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
* 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
   264
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   265
* 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
   266
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   267
* 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
   268
  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
   269
  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
   270
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   271
* 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
   272
  "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
   273
  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
   274
  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
   275
  to this variable 
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   276
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   277
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
   278
for the following :
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
* 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
   281
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   282
* 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
   283
  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
   284
  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
   285
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   286
* 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
   287
  knowing that : 
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   288
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   289
  - 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
   290
    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
   291
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   292
  - 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
   293
    are actually taken in consideration.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   294
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   295
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
   296
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
   297
this entity type is as follow : ::
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   298
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   299
    class EPermission(MetaEntityType):
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   300
	"""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
   301
	"""
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   302
	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
   303
	require_group = SubjectRelation('EGroup', cardinality='+*',
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   304
					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
   305
	require_state = SubjectRelation('State',
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   306
				    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
   307
	# can be used on any entity
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   308
	require_permission = ObjectRelation('**', cardinality='*1', composite='subject',
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   309
					    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
   310
							  "permission should be used in the security "
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   311
							  "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
   312
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   313
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   314
Example of configuration ::
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   315
93
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
    ...
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   318
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   319
    class Version(EntityType):
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   320
	"""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
   321
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   322
	permissions = {'read':   ('managers', 'users', 'guests',),
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   323
		       'update': ('managers', 'logilab', 'owners',),
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   324
		       'delete': ('managers', ),
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   325
		       'add':    ('managers', 'logilab',
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   326
				  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
   327
						 '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
   328
						 'P require_group G'),)}
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
    ...
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   331
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   332
    class version_of(RelationType):
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   333
	"""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
   334
	"""
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   335
	permissions = {'read':   ('managers', 'users', 'guests',),
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   336
		       'delete': ('managers', ),
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   337
		       'add':    ('managers', 'logilab',
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   338
				  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
   339
						 '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
   340
		       }
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   341
	inlined = True
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   342
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   343
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
   344
"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
   345
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
   346
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   347
* 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
   348
  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
   349
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   350
* 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
   351
  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
   352
  ("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
   353
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   354
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
   355
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101
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
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
   358
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   359
* 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
   360
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   361
* 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
   362
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   363
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   364
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
   365
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   366
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
   367
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
   368
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
   369
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
   370
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
   371
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
   372
(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
   373
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
   374
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
   375
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
   376
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
   377
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
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
   380
``````````````````````````````````````````````
c7d6a465b951 updates done to documentation after following instructions for a new cube
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 128
diff changeset
   381
1205
79d33f7db590 [doc] some more small improvements
Emile Anclin <emile.anclin@logilab.fr>
parents: 1164
diff changeset
   382
If you modified your schema, the update is not automatic; indeed, this is 
79d33f7db590 [doc] some more small improvements
Emile Anclin <emile.anclin@logilab.fr>
parents: 1164
diff changeset
   383
in general not a good idea.
79d33f7db590 [doc] some more small improvements
Emile Anclin <emile.anclin@logilab.fr>
parents: 1164
diff changeset
   384
Instead, you call a shell on your application, which is a 
1164
88834894d2d7 explain cubicweb-ctl shell
Emile Anclin <emile.anclin@logilab.fr>
parents: 1163
diff changeset
   385
an interactive python shell, with an appropriate
88834894d2d7 explain cubicweb-ctl shell
Emile Anclin <emile.anclin@logilab.fr>
parents: 1163
diff changeset
   386
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
   387
1159
16a426d214ae use english example names
Emile Anclin <emile.anclin@logilab.fr>
parents: 301
diff changeset
   388
   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
   389
c7d6a465b951 updates done to documentation after following instructions for a new cube
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 128
diff changeset
   390
and type ::
c7d6a465b951 updates done to documentation after following instructions for a new cube
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 128
diff changeset
   391
1159
16a426d214ae use english example names
Emile Anclin <emile.anclin@logilab.fr>
parents: 301
diff changeset
   392
   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
   393
c7d6a465b951 updates done to documentation after following instructions for a new cube
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 128
diff changeset
   394
And restart your application!