schemas/bootstrap.py
changeset 3890 d7a270f50f54
parent 3392 36bcf206e157
parent 3877 7ca53fc72a0a
child 4003 b9436fe77c9e
equal deleted inserted replaced
3810:5b75fd66c80e 3890:d7a270f50f54
    15 
    15 
    16 # not restricted since as "is" is handled as other relations, guests need
    16 # not restricted since as "is" is handled as other relations, guests need
    17 # access to this
    17 # access to this
    18 class CWEType(EntityType):
    18 class CWEType(EntityType):
    19     """define an entity type, used to build the instance schema"""
    19     """define an entity type, used to build the instance schema"""
    20     permissions = META_ETYPE_PERMS
    20     __permissions__ = META_ETYPE_PERMS
    21     name = String(required=True, indexed=True, internationalizable=True,
    21     name = String(required=True, indexed=True, internationalizable=True,
    22                   unique=True, maxsize=64)
    22                   unique=True, maxsize=64)
    23     description = RichString(internationalizable=True,
    23     description = RichString(internationalizable=True,
    24                              description=_('semantic description of this entity type'))
    24                              description=_('semantic description of this entity type'))
    25     # necessary to filter using RQL
    25     # necessary to filter using RQL
    26     final = Boolean(description=_('automatic'))
    26     final = Boolean(description=_('automatic'))
    27 
    27 
    28 
    28 
    29 class CWRType(EntityType):
    29 class CWRType(EntityType):
    30     """define a relation type, used to build the instance schema"""
    30     """define a relation type, used to build the instance schema"""
    31     permissions = META_ETYPE_PERMS
    31     __permissions__ = META_ETYPE_PERMS
    32     name = String(required=True, indexed=True, internationalizable=True,
    32     name = String(required=True, indexed=True, internationalizable=True,
    33                   unique=True, maxsize=64)
    33                   unique=True, maxsize=64)
    34     description = RichString(internationalizable=True,
    34     description = RichString(internationalizable=True,
    35                              description=_('semantic description of this relation type'))
    35                              description=_('semantic description of this relation type'))
    36     symetric = Boolean(description=_('is this relation equivalent in both direction ?'))
    36     symetric = Boolean(description=_('is this relation equivalent in both direction ?'))
    46     """define a final relation: link a final relation type from a non final
    46     """define a final relation: link a final relation type from a non final
    47     entity to a final entity type.
    47     entity to a final entity type.
    48 
    48 
    49     used to build the instance schema
    49     used to build the instance schema
    50     """
    50     """
    51     permissions = META_ETYPE_PERMS
    51     __permissions__ = META_ETYPE_PERMS
    52     relation_type = SubjectRelation('CWRType', cardinality='1*',
    52     relation_type = SubjectRelation('CWRType', cardinality='1*',
    53                                     constraints=[RQLConstraint('O final TRUE')],
    53                                     constraints=[RQLConstraint('O final TRUE')],
    54                                     composite='object')
    54                                     composite='object')
    55     from_entity = SubjectRelation('CWEType', cardinality='1*',
    55     from_entity = SubjectRelation('CWEType', cardinality='1*',
    56                                   constraints=[RQLConstraint('O final FALSE')],
    56                                   constraints=[RQLConstraint('O final FALSE')],
    83     """define a non final relation: link a non final relation type from a non
    83     """define a non final relation: link a non final relation type from a non
    84     final entity to a non final entity type.
    84     final entity to a non final entity type.
    85 
    85 
    86     used to build the instance schema
    86     used to build the instance schema
    87     """
    87     """
    88     permissions = META_ETYPE_PERMS
    88     __permissions__ = META_ETYPE_PERMS
    89     relation_type = SubjectRelation('CWRType', cardinality='1*',
    89     relation_type = SubjectRelation('CWRType', cardinality='1*',
    90                                     constraints=[RQLConstraint('O final FALSE')],
    90                                     constraints=[RQLConstraint('O final FALSE')],
    91                                     composite='object')
    91                                     composite='object')
    92     from_entity = SubjectRelation('CWEType', cardinality='1*',
    92     from_entity = SubjectRelation('CWEType', cardinality='1*',
    93                                   constraints=[RQLConstraint('O final FALSE')],
    93                                   constraints=[RQLConstraint('O final FALSE')],
   113                              description=_('semantic description of this relation'))
   113                              description=_('semantic description of this relation'))
   114 
   114 
   115 
   115 
   116 # not restricted since it has to be read when checking allowed transitions
   116 # not restricted since it has to be read when checking allowed transitions
   117 class RQLExpression(EntityType):
   117 class RQLExpression(EntityType):
   118     """define a rql expression used to define permissions"""
   118     """define a rql expression used to define __permissions__"""
   119     permissions = META_ETYPE_PERMS
   119     __permissions__ = META_ETYPE_PERMS
   120     exprtype = String(required=True, vocabulary=['ERQLExpression', 'RRQLExpression'])
   120     exprtype = String(required=True, vocabulary=['ERQLExpression', 'RRQLExpression'])
   121     mainvars = String(maxsize=8,
   121     mainvars = String(maxsize=8,
   122                       description=_('name of the main variables which should be '
   122                       description=_('name of the main variables which should be '
   123                                     'used in the selection if necessary (comma '
   123                                     'used in the selection if necessary (comma '
   124                                     'separated)'))
   124                                     'separated)'))
   129                                       'the request user. For relation rql expression, '
   129                                       'the request user. For relation rql expression, '
   130                                       'S, O and U are predefined respectivly to the current '
   130                                       'S, O and U are predefined respectivly to the current '
   131                                       'relation\'subject, object and to '
   131                                       'relation\'subject, object and to '
   132                                       'the request user. '))
   132                                       'the request user. '))
   133 
   133 
   134     read_permission = ObjectRelation(('CWEType', 'CWRType'), cardinality='+?', composite='subject',
   134     read_permission = ObjectRelation(('CWEType', 'CWAttribute', 'CWRelation'), cardinality='+?', composite='subject',
   135                                       description=_('rql expression allowing to read entities/relations of this type'))
   135                                       description=_('rql expression allowing to read entities/relations of this type'))
   136     add_permission = ObjectRelation(('CWEType', 'CWRType'), cardinality='*?', composite='subject',
   136     add_permission = ObjectRelation(('CWEType', 'CWAttribute', 'CWRelation'), cardinality='*?', composite='subject',
   137                                      description=_('rql expression allowing to add entities/relations of this type'))
   137                                      description=_('rql expression allowing to add entities/relations of this type'))
   138     delete_permission = ObjectRelation(('CWEType', 'CWRType'), cardinality='*?', composite='subject',
   138     delete_permission = ObjectRelation(('CWEType', 'CWAttribute', 'CWRelation'), cardinality='*?', composite='subject',
   139                                         description=_('rql expression allowing to delete entities/relations of this type'))
   139                                         description=_('rql expression allowing to delete entities/relations of this type'))
   140     update_permission = ObjectRelation('CWEType', cardinality='*?', composite='subject',
   140     update_permission = ObjectRelation('CWEType', cardinality='*?', composite='subject',
   141                                         description=_('rql expression allowing to update entities of this type'))
   141                                         description=_('rql expression allowing to update entities of this type'))
   142 
   142 
   143 
   143 
   144 class CWConstraint(EntityType):
   144 class CWConstraint(EntityType):
   145     """define a schema constraint"""
   145     """define a schema constraint"""
   146     permissions = META_ETYPE_PERMS
   146     __permissions__ = META_ETYPE_PERMS
   147     cstrtype = SubjectRelation('CWConstraintType', cardinality='1*')
   147     cstrtype = SubjectRelation('CWConstraintType', cardinality='1*')
   148     value = String(description=_('depends on the constraint type'))
   148     value = String(description=_('depends on the constraint type'))
   149 
   149 
   150 
   150 
   151 class CWConstraintType(EntityType):
   151 class CWConstraintType(EntityType):
   152     """define a schema constraint type"""
   152     """define a schema constraint type"""
   153     permissions = META_ETYPE_PERMS
   153     __permissions__ = META_ETYPE_PERMS
   154     name = String(required=True, indexed=True, internationalizable=True,
   154     name = String(required=True, indexed=True, internationalizable=True,
   155                   unique=True, maxsize=64)
   155                   unique=True, maxsize=64)
   156 
   156 
   157 
   157 
   158 # not restricted since it has to be read when checking allowed transitions
   158 # not restricted since it has to be read when checking allowed transitions
   159 class CWGroup(EntityType):
   159 class CWGroup(EntityType):
   160     """define a CubicWeb users group"""
   160     """define a CubicWeb users group"""
   161     permissions = META_ETYPE_PERMS
   161     __permissions__ = META_ETYPE_PERMS
   162     name = String(required=True, indexed=True, internationalizable=True,
   162     name = String(required=True, indexed=True, internationalizable=True,
   163                   unique=True, maxsize=64)
   163                   unique=True, maxsize=64)
   164 
   164 
   165     read_permission = ObjectRelation(('CWEType', 'CWRType'), cardinality='+*',
   165     read_permission = ObjectRelation(('CWEType', 'CWAttribute', 'CWRelation'), cardinality='+*',
   166                                       description=_('groups allowed to read entities/relations of this type'))
   166                                       description=_('groups allowed to read entities/relations of this type'))
   167     add_permission = ObjectRelation(('CWEType', 'CWRType'),
   167     add_permission = ObjectRelation(('CWEType', 'CWAttribute', 'CWRelation'),
   168                                      description=_('groups allowed to add entities/relations of this type'))
   168                                      description=_('groups allowed to add entities/relations of this type'))
   169     delete_permission = ObjectRelation(('CWEType', 'CWRType'),
   169     delete_permission = ObjectRelation(('CWEType', 'CWAttribute', 'CWRelation'),
   170                                         description=_('groups allowed to delete entities/relations of this type'))
   170                                         description=_('groups allowed to delete entities/relations of this type'))
   171     update_permission = ObjectRelation('CWEType',
   171     update_permission = ObjectRelation('CWEType',
   172                                         description=_('groups allowed to update entities of this type'))
   172                                         description=_('groups allowed to update entities of this type'))
   173 
   173 
   174 
   174 
   190                                 'value'))
   190                                 'value'))
   191     value = String(internationalizable=True, maxsize=256)
   191     value = String(internationalizable=True, maxsize=256)
   192 
   192 
   193 class relation_type(RelationType):
   193 class relation_type(RelationType):
   194     """link a relation definition to its relation type"""
   194     """link a relation definition to its relation type"""
   195     permissions = META_RTYPE_PERMS
   195     __permissions__ = META_RTYPE_PERMS
   196     inlined = True
   196     inlined = True
   197 
   197 
   198 class from_entity(RelationType):
   198 class from_entity(RelationType):
   199     """link a relation definition to its subject entity type"""
   199     """link a relation definition to its subject entity type"""
   200     permissions = META_RTYPE_PERMS
   200     __permissions__ = META_RTYPE_PERMS
   201     inlined = True
   201     inlined = True
   202 
   202 
   203 class to_entity(RelationType):
   203 class to_entity(RelationType):
   204     """link a relation definition to its object entity type"""
   204     """link a relation definition to its object entity type"""
   205     permissions = META_RTYPE_PERMS
   205     __permissions__ = META_RTYPE_PERMS
   206     inlined = True
   206     inlined = True
   207 
   207 
   208 class constrained_by(RelationType):
   208 class constrained_by(RelationType):
   209     """constraints applying on this relation"""
   209     """constraints applying on this relation"""
   210     permissions = META_RTYPE_PERMS
   210     __permissions__ = META_RTYPE_PERMS
   211 
   211 
   212 class cstrtype(RelationType):
   212 class cstrtype(RelationType):
   213     """constraint factory"""
   213     """constraint factory"""
   214     permissions = META_RTYPE_PERMS
   214     __permissions__ = META_RTYPE_PERMS
   215     inlined = True
   215     inlined = True
   216 
   216 
   217 class read_permission(RelationType):
   217 class read_permission(RelationType):
   218     """core relation giving to a group the permission to read an entity or
   218     """core relation giving to a group the permission to read an entity or
   219     relation type
   219     relation type
   220     """
   220     """
   221     permissions = META_RTYPE_PERMS
   221     __permissions__ = META_RTYPE_PERMS
   222 
   222 
   223 class add_permission(RelationType):
   223 class add_permission(RelationType):
   224     """core relation giving to a group the permission to add an entity or
   224     """core relation giving to a group the permission to add an entity or
   225     relation type
   225     relation type
   226     """
   226     """
   227     permissions = META_RTYPE_PERMS
   227     __permissions__ = META_RTYPE_PERMS
   228 
   228 
   229 class delete_permission(RelationType):
   229 class delete_permission(RelationType):
   230     """core relation giving to a group the permission to delete an entity or
   230     """core relation giving to a group the permission to delete an entity or
   231     relation type
   231     relation type
   232     """
   232     """
   233     permissions = META_RTYPE_PERMS
   233     __permissions__ = META_RTYPE_PERMS
   234 
   234 
   235 class update_permission(RelationType):
   235 class update_permission(RelationType):
   236     """core relation giving to a group the permission to update an entity type
   236     """core relation giving to a group the permission to update an entity type
   237     """
   237     """
   238     permissions = META_RTYPE_PERMS
   238     __permissions__ = META_RTYPE_PERMS
   239 
   239 
   240 
   240 
   241 class is_(RelationType):
   241 class is_(RelationType):
   242     """core relation indicating the type of an entity
   242     """core relation indicating the type of an entity
   243     """
   243     """
   244     name = 'is'
   244     name = 'is'
   245     # don't explicitly set composite here, this is handled anyway
   245     # don't explicitly set composite here, this is handled anyway
   246     #composite = 'object'
   246     #composite = 'object'
   247     permissions = {
   247     __permissions__ = {
   248         'read':   ('managers', 'users', 'guests'),
   248         'read':   ('managers', 'users', 'guests'),
   249         'add':    (),
   249         'add':    (),
   250         'delete': (),
   250         'delete': (),
   251         }
   251         }
   252     cardinality = '1*'
   252     cardinality = '1*'
   257     """core relation indicating the types (including specialized types)
   257     """core relation indicating the types (including specialized types)
   258     of an entity
   258     of an entity
   259     """
   259     """
   260     # don't explicitly set composite here, this is handled anyway
   260     # don't explicitly set composite here, this is handled anyway
   261     #composite = 'object'
   261     #composite = 'object'
   262     permissions = {
   262     __permissions__ = {
   263         'read':   ('managers', 'users', 'guests'),
   263         'read':   ('managers', 'users', 'guests'),
   264         'add':    (),
   264         'add':    (),
   265         'delete': (),
   265         'delete': (),
   266         }
   266         }
   267     cardinality = '+*'
   267     cardinality = '+*'
   268     subject = '*'
   268     subject = '*'
   269     object = 'CWEType'
   269     object = 'CWEType'
   270 
   270 
   271 class specializes(RelationType):
   271 class specializes(RelationType):
   272     name = 'specializes'
   272     name = 'specializes'
   273     permissions = {
   273     __permissions__ = {
   274         'read':   ('managers', 'users', 'guests'),
   274         'read':   ('managers', 'users', 'guests'),
   275         'add':    ('managers',),
   275         'add':    ('managers',),
   276         'delete': ('managers',),
   276         'delete': ('managers',),
   277         }
   277         }
   278     cardinality = '?*'
   278     cardinality = '?*'