schemas/bootstrap.py
branchstable
changeset 4570 ede247bbbf62
parent 4535 71c86a315a9a
child 4588 36b700c00d38
equal deleted inserted replaced
4569:1acd90d0cb59 4570:ede247bbbf62
     7 """
     7 """
     8 __docformat__ = "restructuredtext en"
     8 __docformat__ = "restructuredtext en"
     9 _ = unicode
     9 _ = unicode
    10 
    10 
    11 from yams.buildobjs import (EntityType, RelationType, SubjectRelation,
    11 from yams.buildobjs import (EntityType, RelationType, SubjectRelation,
    12                             ObjectRelation, RichString, String, Boolean, Int)
    12                             RichString, String, Boolean, Int)
    13 from cubicweb.schema import RQLConstraint
    13 from cubicweb.schema import RQLConstraint
    14 from cubicweb.schemas import META_ETYPE_PERMS, META_RTYPE_PERMS
    14 from cubicweb.schemas import META_ETYPE_PERMS, META_RTYPE_PERMS
    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
   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', 'CWAttribute', 'CWRelation'), cardinality='*?', composite='subject',
       
   135                                       description=_('rql expression allowing to read entities/relations of this type'))
       
   136     add_permission = ObjectRelation(('CWEType', 'CWAttribute', 'CWRelation'), cardinality='*?', composite='subject',
       
   137                                      description=_('rql expression allowing to add entities/relations of this type'))
       
   138     delete_permission = ObjectRelation(('CWEType', 'CWAttribute', 'CWRelation'), cardinality='*?', composite='subject',
       
   139                                         description=_('rql expression allowing to delete entities/relations of this type'))
       
   140     update_permission = ObjectRelation('CWEType', cardinality='*?', composite='subject',
       
   141                                         description=_('rql expression allowing to update entities of this type'))
       
   142 
       
   143 
   134 
   144 class CWConstraint(EntityType):
   135 class CWConstraint(EntityType):
   145     """define a schema constraint"""
   136     """define a schema constraint"""
   146     __permissions__ = META_ETYPE_PERMS
   137     __permissions__ = META_ETYPE_PERMS
   147     cstrtype = SubjectRelation('CWConstraintType', cardinality='1*')
   138     cstrtype = SubjectRelation('CWConstraintType', cardinality='1*')
   159 class CWGroup(EntityType):
   150 class CWGroup(EntityType):
   160     """define a CubicWeb users group"""
   151     """define a CubicWeb users group"""
   161     __permissions__ = META_ETYPE_PERMS
   152     __permissions__ = META_ETYPE_PERMS
   162     name = String(required=True, indexed=True, internationalizable=True,
   153     name = String(required=True, indexed=True, internationalizable=True,
   163                   unique=True, maxsize=64)
   154                   unique=True, maxsize=64)
   164 
       
   165     read_permission = ObjectRelation(('CWEType', 'CWAttribute', 'CWRelation'), cardinality='**',
       
   166                                       description=_('groups allowed to read entities/relations of this type'))
       
   167     add_permission = ObjectRelation(('CWEType', 'CWAttribute', 'CWRelation'),
       
   168                                      description=_('groups allowed to add entities/relations of this type'))
       
   169     delete_permission = ObjectRelation(('CWEType', 'CWAttribute', 'CWRelation'),
       
   170                                         description=_('groups allowed to delete entities/relations of this type'))
       
   171     update_permission = ObjectRelation('CWEType',
       
   172                                         description=_('groups allowed to update entities of this type'))
       
   173 
       
   174 
   155 
   175 
   156 
   176 class CWProperty(EntityType):
   157 class CWProperty(EntityType):
   177     """used for cubicweb configuration. Once a property has been created you
   158     """used for cubicweb configuration. Once a property has been created you
   178     can't change the key.
   159     can't change the key.
   213     """constraint factory"""
   194     """constraint factory"""
   214     __permissions__ = META_RTYPE_PERMS
   195     __permissions__ = META_RTYPE_PERMS
   215     inlined = True
   196     inlined = True
   216 
   197 
   217 class read_permission(RelationType):
   198 class read_permission(RelationType):
   218     """core relation giving to a group the permission to read an entity or
   199     """grant permission to read entity or relation through a group or rql
   219     relation type
   200     expression
   220     """
   201     """
   221     __permissions__ = META_RTYPE_PERMS
   202     __permissions__ = META_RTYPE_PERMS
       
   203     subject = ('CWEType', 'CWAttribute', 'CWRelation')
       
   204     object = ('CWGroup', 'RQLExpression')
       
   205     cardinality = '*?'
       
   206     composite = 'subject'
   222 
   207 
   223 class add_permission(RelationType):
   208 class add_permission(RelationType):
   224     """core relation giving to a group the permission to add an entity or
   209     """grant permission to add entity or relation through a group or rql
   225     relation type
   210     expression
   226     """
   211     """
   227     __permissions__ = META_RTYPE_PERMS
   212     __permissions__ = META_RTYPE_PERMS
       
   213     subject = ('CWEType', 'CWRelation')
       
   214     object = ('CWGroup', 'RQLExpression')
       
   215     cardinality = '*?'
       
   216     composite = 'subject'
   228 
   217 
   229 class delete_permission(RelationType):
   218 class delete_permission(RelationType):
   230     """core relation giving to a group the permission to delete an entity or
   219     """grant permission to delete entity or relation through a group or rql
   231     relation type
   220     expression
   232     """
   221     """
   233     __permissions__ = META_RTYPE_PERMS
   222     __permissions__ = META_RTYPE_PERMS
       
   223     subject = ('CWEType', 'CWRelation')
       
   224     object = ('CWGroup', 'RQLExpression')
       
   225     cardinality = '*?'
       
   226     composite = 'subject'
   234 
   227 
   235 class update_permission(RelationType):
   228 class update_permission(RelationType):
   236     """core relation giving to a group the permission to update an entity type
   229     """grant permission to update entity or attribute through a group or rql
   237     """
   230     expression
   238     __permissions__ = META_RTYPE_PERMS
   231     """
       
   232     __permissions__ = META_RTYPE_PERMS
       
   233     subject = ('CWEType', 'CWAttribute')
       
   234     object = ('CWGroup', 'RQLExpression')
       
   235     cardinality = '*?'
       
   236     composite = 'subject'
   239 
   237 
   240 
   238 
   241 class is_(RelationType):
   239 class is_(RelationType):
   242     """core relation indicating the type of an entity
   240     """core relation indicating the type of an entity
   243     """
   241     """