equal
deleted
inserted
replaced
1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # |
3 # |
4 # This file is part of CubicWeb. |
4 # This file is part of CubicWeb. |
5 # |
5 # |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
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 |
67 |
|
68 SKIP_COMPOSITE_RELS = [('cw_source', 'subject')] |
|
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', |
72 'RQLExpression', |
74 'RQLExpression', |
81 WORKFLOW_TYPES = set(('Transition', 'State', 'TrInfo', 'Workflow', |
83 WORKFLOW_TYPES = set(('Transition', 'State', 'TrInfo', 'Workflow', |
82 'WorkflowTransition', 'BaseTransition', |
84 'WorkflowTransition', 'BaseTransition', |
83 'SubWorkflowExitPoint')) |
85 'SubWorkflowExitPoint')) |
84 |
86 |
85 INTERNAL_TYPES = set(('CWProperty', 'CWPermission', 'CWCache', 'ExternalUri', |
87 INTERNAL_TYPES = set(('CWProperty', 'CWPermission', 'CWCache', 'ExternalUri', |
86 'CWSource', 'CWSourceHostConfig', |
88 'CWSource', 'CWSourceHostConfig', 'CWSourceSchemaConfig')) |
87 )) |
|
88 |
89 |
89 |
90 |
90 _LOGGER = getLogger('cubicweb.schemaloader') |
91 _LOGGER = getLogger('cubicweb.schemaloader') |
91 |
92 |
92 # schema entities created from serialized schema have an eid rproperty |
93 # schema entities created from serialized schema have an eid rproperty |
106 'add': ('managers',), |
107 'add': ('managers',), |
107 'delete': ('managers',), |
108 'delete': ('managers',), |
108 } |
109 } |
109 PUB_SYSTEM_ATTR_PERMS = { |
110 PUB_SYSTEM_ATTR_PERMS = { |
110 'read': ('managers', 'users', 'guests',), |
111 'read': ('managers', 'users', 'guests',), |
111 'update': ('managers',), |
112 'update': ('managers',), |
112 } |
113 } |
113 RO_REL_PERMS = { |
114 RO_REL_PERMS = { |
114 'read': ('managers', 'users', 'guests',), |
115 'read': ('managers', 'users', 'guests',), |
115 'add': (), |
116 'add': (), |
116 'delete': (), |
117 'delete': (), |
366 for groups in self.permissions.itervalues(): |
367 for groups in self.permissions.itervalues(): |
367 for group_or_rqlexpr in groups: |
368 for group_or_rqlexpr in groups: |
368 if isinstance(group_or_rqlexpr, RRQLExpression): |
369 if isinstance(group_or_rqlexpr, RRQLExpression): |
369 msg = "can't use RRQLExpression on %s, use an ERQLExpression" |
370 msg = "can't use RRQLExpression on %s, use an ERQLExpression" |
370 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) |
371 |
380 |
372 def attribute_definitions(self): |
381 def attribute_definitions(self): |
373 """return an iterator on attribute definitions |
382 """return an iterator on attribute definitions |
374 |
383 |
375 attribute relations are a subset of subject relations where the |
384 attribute relations are a subset of subject relations where the |