schema.py
changeset 6951 cb6314b09e0f
parent 6949 267ce7cf77f1
child 7085 36e91d19188b
equal deleted inserted replaced
6950:8a17e6e34f0f 6951:cb6314b09e0f
    62                      # cwproperty
    62                      # cwproperty
    63                      'for_user',
    63                      'for_user',
    64                      )) | WORKFLOW_RTYPES
    64                      )) | WORKFLOW_RTYPES
    65 NO_I18NCONTEXT = META_RTYPES | WORKFLOW_RTYPES
    65 NO_I18NCONTEXT = META_RTYPES | WORKFLOW_RTYPES
    66 NO_I18NCONTEXT.add('require_permission')
    66 NO_I18NCONTEXT.add('require_permission')
       
    67 
       
    68 SKIP_COMPOSITE_RELS = [('cw_source', 'subject')]
    67 
    69 
    68 # set of entity and relation types used to build the schema
    70 # set of entity and relation types used to build the schema
    69 SCHEMA_TYPES = set((
    71 SCHEMA_TYPES = set((
    70     'CWEType', 'CWRType', 'CWAttribute', 'CWRelation',
    72     'CWEType', 'CWRType', 'CWAttribute', 'CWRelation',
    71     'CWConstraint', 'CWConstraintType', 'CWUniqueTogetherConstraint',
    73     'CWConstraint', 'CWConstraintType', 'CWUniqueTogetherConstraint',
   365         for groups in self.permissions.itervalues():
   367         for groups in self.permissions.itervalues():
   366             for group_or_rqlexpr in groups:
   368             for group_or_rqlexpr in groups:
   367                 if isinstance(group_or_rqlexpr, RRQLExpression):
   369                 if isinstance(group_or_rqlexpr, RRQLExpression):
   368                     msg = "can't use RRQLExpression on %s, use an ERQLExpression"
   370                     msg = "can't use RRQLExpression on %s, use an ERQLExpression"
   369                     raise BadSchemaDefinition(msg % self.type)
   371                     raise BadSchemaDefinition(msg % self.type)
       
   372 
       
   373     def is_subobject(self, strict=False, skiprels=None):
       
   374         if skiprels is None:
       
   375             skiprels = SKIP_COMPOSITE_RELS
       
   376         else:
       
   377             skiprels += SKIP_COMPOSITE_RELS
       
   378         return super(CubicWebEntitySchema, self).is_subobject(strict,
       
   379                                                               skiprels=skiprels)
   370 
   380 
   371     def attribute_definitions(self):
   381     def attribute_definitions(self):
   372         """return an iterator on attribute definitions
   382         """return an iterator on attribute definitions
   373 
   383 
   374         attribute relations are a subset of subject relations where the
   384         attribute relations are a subset of subject relations where the