# HG changeset patch # User Sylvain Thénault # Date 1267541066 -3600 # Node ID 13a5d3a7410ee3dc2a3ef4cf7581e392db4f3ab4 # Parent 6bf17f8109755afeaf7946b04737f5d748069522 [schema] tweaks meta-relations and schema/workflow entities attributes permissions diff -r 6bf17f810975 -r 13a5d3a7410e schema.py --- a/schema.py Tue Mar 02 15:43:26 2010 +0100 +++ b/schema.py Tue Mar 02 15:44:26 2010 +0100 @@ -394,7 +394,8 @@ if need_has_text is None: need_has_text = may_need_has_text if need_has_text and not has_has_text and not deletion: - rdef = ybo.RelationDefinition(self.type, 'has_text', 'String') + rdef = ybo.RelationDefinition(self.type, 'has_text', 'String', + __permissions__=RO_ATTR_PERMS) self.schema.add_relation_def(rdef) elif not need_has_text and has_has_text: self.schema.del_relation_def(self.type, 'has_text', 'String') @@ -516,9 +517,11 @@ if not eschema.final: # automatically add the eid relation to non final entity types rdef = ybo.RelationDefinition(eschema.type, 'eid', 'Int', - cardinality='11', uid=True) + cardinality='11', uid=True, + __permissions__=RO_ATTR_PERMS) self.add_relation_def(rdef) - rdef = ybo.RelationDefinition(eschema.type, 'identity', eschema.type) + rdef = ybo.RelationDefinition(eschema.type, 'identity', eschema.type, + __permissions__=RO_REL_PERMS) self.add_relation_def(rdef) self._eid_index[eschema.eid] = eschema return eschema diff -r 6bf17f810975 -r 13a5d3a7410e schemas/base.py --- a/schemas/base.py Tue Mar 02 15:43:26 2010 +0100 +++ b/schemas/base.py Tue Mar 02 15:44:26 2010 +0100 @@ -118,18 +118,21 @@ class creation_date(RelationType): """creation time of an entity""" + __permissions__ = PUB_SYSTEM_ATTR_PERMS cardinality = '11' subject = '*' object = 'Datetime' class modification_date(RelationType): """latest modification time of an entity""" + __permissions__ = PUB_SYSTEM_ATTR_PERMS cardinality = '11' subject = '*' object = 'Datetime' class cwuri(RelationType): """internal entity uri""" + __permissions__ = PUB_SYSTEM_ATTR_PERMS cardinality = '11' subject = '*' object = 'String' diff -r 6bf17f810975 -r 13a5d3a7410e schemas/bootstrap.py --- a/schemas/bootstrap.py Tue Mar 02 15:43:26 2010 +0100 +++ b/schemas/bootstrap.py Tue Mar 02 15:44:26 2010 +0100 @@ -307,3 +307,13 @@ cardinality = '?*' subject = 'CWEType' object = 'CWEType' + +def post_build_callback(schema): + """set attributes permissions for schema/workflow entities""" + from cubicweb.schema import SCHEMA_TYPES, WORKFLOW_TYPES, META_RTYPES + for eschema in schema.entities(): + if eschema in SCHEMA_TYPES or eschema in WORKFLOW_TYPES: + for rschema in eschema.subject_relations(): + if rschema.final and not rschema in META_RTYPES: + rdef = eschema.rdef(rschema) + rdef.permissions = PUB_SYSTEM_ATTR_PERMS