doc/book/en/04-02-schema-definition.en.txt
author Sylvain Thenault <sylvain.thenault@logilab.fr>
Fri, 21 Nov 2008 07:50:34 +0100
changeset 122 ac5ea13f8945
parent 101 c9138325b89f
permissions -rw-r--r--
merged into the security definition section
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
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
     6
An entity type is defined by a Python class which inherits `EntityType`. The
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
     7
class name correponds to the type name. Then the content of the class contains
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
     8
the description of attributes and relations for the defined entity type,
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
     9
by example ::
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    10
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    11
  class Personne(EntityType):
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    12
    """A person with the properties and the relations necessarry for my
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    13
    application"""
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    14
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    15
    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
    16
    first_name = String(required=True, fulltextindexed=True)
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    17
    title = String(vocabulary=('M', 'Mme', 'Mlle'))
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    18
    date_of_birth = Date()
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    19
    works_for = SubjectRelation('Company', cardinality='?*')
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    20
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    21
* 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
    22
  or the relation in `CubicWeb` application.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    23
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    24
* all built-in types are available : `String`, `Int`, `Float`,
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    25
  `Boolean`, `Date`, `Datetime`, `Time`, `Byte`.
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    26
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    27
* 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
    28
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    29
  - `eid` (`Int`)
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    30
  
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    31
  - `creation_date` (`Datetime`)
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
  - `modification_date` (`Datetime`)
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    34
  
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    35
  - `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
    36
  
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    37
  - `owned_by` (`EUser`) (who does the entity belongs to, by default the 
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    38
     creator but not necessarry and it could have multiple owners)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    39
     
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    40
  - `is` (`EEType`)
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    41
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    42
  
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    43
* it is also possible to define relations of type object by using `ObjectRelation`
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    44
  instead of `SubjectRelation`
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    45
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    46
* the first argument of `SubjectRelation` and `ObjectRelation` gives respectively
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    47
  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
    48
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    49
  * 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
    50
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    51
  * a tuple of string correponding to multiple entities types
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
  * special string such as follows :
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
    - "**" : all types of entities
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    56
    - "*" : all types of non-meta entities 
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    57
    - "@" : 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
    58
      the basic schema description)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    59
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    60
* 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
    61
  (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
    62
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    63
* optional properties for attributes and relations : 
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    64
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    65
  - `description` : string describing an attribute or a relation. By default
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    66
    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
    67
    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
    68
    function `_` to be properly internationalized.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    69
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    70
  - `constraints` : list of conditions/constraints that the relation needs to
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    71
    satisfy (c.f. `Contraints`_)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    72
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    73
  - `cardinality` : two characters string which specify the cardinality of the
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    74
    relation. The first character defines the cardinality of the relation on
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    75
    the subject, the second on the object of the relation. When a relation
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    76
    has multiple possible subjects or objects, the cardinality applies to all
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    77
    and not on a one to one basis (so it must be consistent...). The possible
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    78
    values are inspired from regular expressions syntax :
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    79
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    80
    * `1`: 1..1
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    81
    * `?`: 0..1
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    82
    * `+`: 1..n
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    83
    * `*`: 0..n
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    84
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    85
  - `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
    86
    default)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    87
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    88
* optionnal properties for attributes : 
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    89
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    90
  - `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
    91
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    92
  - `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
    93
    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
    94
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
    95
  - `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
    96
    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
    97
    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
    98
    attribute.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    99
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   100
  - `default` : default value of the attribute. In case of date types, the values
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   101
    which could be used correpond to the RQL keywords `TODAY` and `NOW`.
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   102
  
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   103
  - `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
   104
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   105
* optionnal properties of type `String` : 
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   106
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   107
  - `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
   108
    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
   109
    as well*)
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
  - `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
   112
    is internationalizable (false by default)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   113
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   114
  - `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
   115
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   116
* optionnal properties for relations : 
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
  - `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
   119
    is composed of the objects of the relations. For the opposite case (when
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   120
    the object is composed of the subjects of the relation), we just need
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   121
    to set 'object' as the value. The composition implies that when the relation
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   122
    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
   123
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   124
Contraints
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   125
``````````
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   126
By default, the available constraints types are :
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
* `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
   129
  string (generic case of `maxsize`)
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   130
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   131
* `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
   132
  numeric types
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   133
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   134
* `UniqueConstraint` : identical to "unique=True"
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
* `StaticVocabularyConstraint` : identical to "vocabulary=(...)"
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
* `RQLConstraint` : allows to specify a RQL query that needs to be satisfied
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   139
  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
   140
  `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
   141
  relation.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   142
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   143
* `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
   144
  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
   145
  restrict the values listed in the drop-down menu of editing form, but it does
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   146
  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
   147
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   148
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   149
Relation definition
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   150
-------------------
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   151
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   152
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
   153
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   154
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
   155
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
   156
a description of the properties of this type of relation, and could as well 
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   157
contains a string for the subject and a string for the object. This allows to create
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   158
new definition of associated relations, (so that the class can have the 
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   159
definition properties from the relation) by example ::
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   160
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   161
  class locked_by(RelationType):
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   162
    """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
   163
    inlined = True
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   164
    cardinality = '?*'
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   165
    subject = '*'
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   166
    object = 'EUser'
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   167
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   168
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
   169
(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
   170
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
* `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
   173
  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
   174
  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
   175
  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
   176
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   177
* `symetric` : boolean indication that the relation is symetrical, which
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   178
  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
   179
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   180
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
   181
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
   182
and `ObjectRelation`.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   183
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   184
When a relation is not inlined and not symetrical, and it does not require
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   185
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
   186
`ObjectRelation`) is all we need.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   187
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   188
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   189
The security model
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
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   192
Le modèle de sécurité de CubicWeb est un modèle fondé sur des `Access
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   193
Control List`. Les notions sont les suivantes :
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
* utilisateurs et groupes d'utilisateurs
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   196
* un utilisateur appartient à au moins un groupe
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   197
* droits (lire, modifier, créer, supprimer) 
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   198
* les droits sont attribués aux groupes (et non aux utilisateurs)
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   199
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   200
Pour CubicWeb plus spécifiquement :
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   201
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   202
* on associe les droits au niveau des schemas d'entites / relations
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   203
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   204
* pour chaque type d'entité, on distingue les droits de lecture,
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   205
  ajout, modification et suppression
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   206
  
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   207
* pour chaque type de relation, on distingue les droits de lecture,
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   208
  ajout et suppression (on ne peut pas modifer une relation)
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   209
  
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   210
* les groupes de base sont : Administrateurs, Utilisateurs, Invités
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   211
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   212
* les utilisateurs font par défaut parti du groupe Utilisateurs
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   213
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   214
* on a un groupe virtuel "Utilisateurs Propriétaires", auquel on peut
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   215
  associer uniquement les droits de suppression et de modification
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   216
  
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   217
* on ne peut pas mettre d'utilisateurs dans ce groupe, ils y sont
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   218
  ajoutés implicitement dans le contexte des objets dont ils sont
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   219
  propriétaires
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   220
  
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   221
* les droits de ce groupe ne sont vérifiés que sur
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   222
  modification / suppression si tous les autres groupes auxquels
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   223
  l'utilisateur appartient se sont vu interdir l'accès
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   224
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   225
  
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   226
Permissions definition
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   227
``````````````````````
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   228
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   229
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
   230
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
   231
(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
   232
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   233
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
   234
`delete`.
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   235
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   236
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
   237
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   238
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
   239
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
   240
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
   241
satisfied.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   242
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   243
The standard groups are :
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   244
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   245
* `guests`
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   246
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   247
* `users`
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   248
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   249
* `managers`
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   250
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   251
* `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
   252
  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
   253
  type.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   254
122
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   255
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
   256
of the cube (``migration/precreate.py``).
ac5ea13f8945 merged into the security definition section
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 101
diff changeset
   257
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
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
   260
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   261
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
   262
(`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
   263
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   264
RQL expression for entity type permission :
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   265
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   266
* 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
   267
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   268
* 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
   269
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   270
* 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
   271
  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
   272
  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
   273
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   274
* 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
   275
  "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
   276
  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
   277
  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
   278
  to this variable 
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
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
   281
for the following :
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   282
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   283
* 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
   284
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   285
* 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
   286
  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
   287
  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
   288
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   289
* 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
   290
  knowing that : 
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
  - 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
   293
    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
   294
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   295
  - 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
   296
    are actually taken in consideration.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   297
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   298
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
   299
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
   300
this entity type is as follow : ::
93
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
    class EPermission(MetaEntityType):
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   303
	"""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
   304
	"""
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   305
	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
   306
	require_group = SubjectRelation('EGroup', cardinality='+*',
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   307
					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
   308
	require_state = SubjectRelation('State',
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   309
				    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
   310
	# can be used on any entity
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   311
	require_permission = ObjectRelation('**', cardinality='*1', composite='subject',
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   312
					    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
   313
							  "permission should be used in the security "
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   314
							  "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
   315
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   316
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   317
Example of configuration ::
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   318
93
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
    ...
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
    class Version(EntityType):
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   323
	"""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
   324
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   325
	permissions = {'read':   ('managers', 'users', 'guests',),
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   326
		       'update': ('managers', 'logilab', 'owners',),
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   327
		       'delete': ('managers', ),
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   328
		       'add':    ('managers', 'logilab',
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   329
				  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
   330
						 '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
   331
						 'P require_group G'),)}
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
    ...
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
    class version_of(RelationType):
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   336
	"""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
   337
	"""
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   338
	permissions = {'read':   ('managers', 'users', 'guests',),
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   339
		       'delete': ('managers', ),
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   340
		       'add':    ('managers', 'logilab',
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   341
				  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
   342
						 '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
   343
		       }
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   344
	inlined = True
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   345
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   346
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
   347
"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
   348
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
   349
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   350
* 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
   351
  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
   352
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   353
* 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
   354
  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
   355
  ("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
   356
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   357
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
   358
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   359
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   360
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
   361
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   362
* 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
   363
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   364
* 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
   365
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   366
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   367
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
   368
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101
c9138325b89f [doc] Initial translation for data model chapter.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 93
diff changeset
   369
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
   370
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
   371
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
   372
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
   373
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
   374
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
   375
(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
   376
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
   377
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
   378
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
   379
to check properly the permissions so that it would show up if necessary.