schemas/bootstrap.py
branchreldefsecurity
changeset 3877 7ca53fc72a0a
parent 2476 1294a6bdf3bf
child 3890 d7a270f50f54
equal deleted inserted replaced
3876:1169d3154be6 3877:7ca53fc72a0a
    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 
   175 
   175 
   176 class relation_type(RelationType):
   176 class relation_type(RelationType):
   177     """link a relation definition to its relation type"""
   177     """link a relation definition to its relation type"""
   178     permissions = META_RTYPE_PERMS
   178     __permissions__ = META_RTYPE_PERMS
   179     inlined = True
   179     inlined = True
   180 
   180 
   181 class from_entity(RelationType):
   181 class from_entity(RelationType):
   182     """link a relation definition to its subject entity type"""
   182     """link a relation definition to its subject entity type"""
   183     permissions = META_RTYPE_PERMS
   183     __permissions__ = META_RTYPE_PERMS
   184     inlined = True
   184     inlined = True
   185 
   185 
   186 class to_entity(RelationType):
   186 class to_entity(RelationType):
   187     """link a relation definition to its object entity type"""
   187     """link a relation definition to its object entity type"""
   188     permissions = META_RTYPE_PERMS
   188     __permissions__ = META_RTYPE_PERMS
   189     inlined = True
   189     inlined = True
   190 
   190 
   191 class constrained_by(RelationType):
   191 class constrained_by(RelationType):
   192     """constraints applying on this relation"""
   192     """constraints applying on this relation"""
   193     permissions = META_RTYPE_PERMS
   193     __permissions__ = META_RTYPE_PERMS
   194 
   194 
   195 class cstrtype(RelationType):
   195 class cstrtype(RelationType):
   196     """constraint factory"""
   196     """constraint factory"""
   197     permissions = META_RTYPE_PERMS
   197     __permissions__ = META_RTYPE_PERMS
   198     inlined = True
   198     inlined = True
   199 
   199 
   200 class read_permission(RelationType):
   200 class read_permission(RelationType):
   201     """core relation giving to a group the permission to read an entity or
   201     """core relation giving to a group the permission to read an entity or
   202     relation type
   202     relation type
   203     """
   203     """
   204     permissions = META_RTYPE_PERMS
   204     __permissions__ = META_RTYPE_PERMS
   205 
   205 
   206 class add_permission(RelationType):
   206 class add_permission(RelationType):
   207     """core relation giving to a group the permission to add an entity or
   207     """core relation giving to a group the permission to add an entity or
   208     relation type
   208     relation type
   209     """
   209     """
   210     permissions = META_RTYPE_PERMS
   210     __permissions__ = META_RTYPE_PERMS
   211 
   211 
   212 class delete_permission(RelationType):
   212 class delete_permission(RelationType):
   213     """core relation giving to a group the permission to delete an entity or
   213     """core relation giving to a group the permission to delete an entity or
   214     relation type
   214     relation type
   215     """
   215     """
   216     permissions = META_RTYPE_PERMS
   216     __permissions__ = META_RTYPE_PERMS
   217 
   217 
   218 class update_permission(RelationType):
   218 class update_permission(RelationType):
   219     """core relation giving to a group the permission to update an entity type
   219     """core relation giving to a group the permission to update an entity type
   220     """
   220     """
   221     permissions = META_RTYPE_PERMS
   221     __permissions__ = META_RTYPE_PERMS
   222 
   222 
   223 
   223 
   224 class is_(RelationType):
   224 class is_(RelationType):
   225     """core relation indicating the type of an entity
   225     """core relation indicating the type of an entity
   226     """
   226     """
   227     name = 'is'
   227     name = 'is'
   228     # don't explicitly set composite here, this is handled anyway
   228     # don't explicitly set composite here, this is handled anyway
   229     #composite = 'object'
   229     #composite = 'object'
   230     permissions = {
   230     __permissions__ = {
   231         'read':   ('managers', 'users', 'guests'),
   231         'read':   ('managers', 'users', 'guests'),
   232         'add':    (),
   232         'add':    (),
   233         'delete': (),
   233         'delete': (),
   234         }
   234         }
   235     cardinality = '1*'
   235     cardinality = '1*'
   240     """core relation indicating the types (including specialized types)
   240     """core relation indicating the types (including specialized types)
   241     of an entity
   241     of an entity
   242     """
   242     """
   243     # don't explicitly set composite here, this is handled anyway
   243     # don't explicitly set composite here, this is handled anyway
   244     #composite = 'object'
   244     #composite = 'object'
   245     permissions = {
   245     __permissions__ = {
   246         'read':   ('managers', 'users', 'guests'),
   246         'read':   ('managers', 'users', 'guests'),
   247         'add':    (),
   247         'add':    (),
   248         'delete': (),
   248         'delete': (),
   249         }
   249         }
   250     cardinality = '+*'
   250     cardinality = '+*'
   251     subject = '*'
   251     subject = '*'
   252     object = 'CWEType'
   252     object = 'CWEType'
   253 
   253 
   254 class specializes(RelationType):
   254 class specializes(RelationType):
   255     name = 'specializes'
   255     name = 'specializes'
   256     permissions = {
   256     __permissions__ = {
   257         'read':   ('managers', 'users', 'guests'),
   257         'read':   ('managers', 'users', 'guests'),
   258         'add':    ('managers',),
   258         'add':    ('managers',),
   259         'delete': ('managers',),
   259         'delete': ('managers',),
   260         }
   260         }
   261     cardinality = '?*'
   261     cardinality = '?*'