schema.py
branchstable
changeset 4755 13a5d3a7410e
parent 4754 6bf17f810975
child 4757 5d937aeaa6fb
equal deleted inserted replaced
4754:6bf17f810975 4755:13a5d3a7410e
   392                 else:
   392                 else:
   393                     need_has_text = False
   393                     need_has_text = False
   394         if need_has_text is None:
   394         if need_has_text is None:
   395             need_has_text = may_need_has_text
   395             need_has_text = may_need_has_text
   396         if need_has_text and not has_has_text and not deletion:
   396         if need_has_text and not has_has_text and not deletion:
   397             rdef = ybo.RelationDefinition(self.type, 'has_text', 'String')
   397             rdef = ybo.RelationDefinition(self.type, 'has_text', 'String',
       
   398                                           __permissions__=RO_ATTR_PERMS)
   398             self.schema.add_relation_def(rdef)
   399             self.schema.add_relation_def(rdef)
   399         elif not need_has_text and has_has_text:
   400         elif not need_has_text and has_has_text:
   400             self.schema.del_relation_def(self.type, 'has_text', 'String')
   401             self.schema.del_relation_def(self.type, 'has_text', 'String')
   401 
   402 
   402     def schema_entity(self):
   403     def schema_entity(self):
   514         assert re.match(r'[A-Z][A-Za-z0-9]*[a-z]+[0-9]*$', edef.name), repr(edef.name)
   515         assert re.match(r'[A-Z][A-Za-z0-9]*[a-z]+[0-9]*$', edef.name), repr(edef.name)
   515         eschema = super(CubicWebSchema, self).add_entity_type(edef)
   516         eschema = super(CubicWebSchema, self).add_entity_type(edef)
   516         if not eschema.final:
   517         if not eschema.final:
   517             # automatically add the eid relation to non final entity types
   518             # automatically add the eid relation to non final entity types
   518             rdef = ybo.RelationDefinition(eschema.type, 'eid', 'Int',
   519             rdef = ybo.RelationDefinition(eschema.type, 'eid', 'Int',
   519                                           cardinality='11', uid=True)
   520                                           cardinality='11', uid=True,
       
   521                                           __permissions__=RO_ATTR_PERMS)
   520             self.add_relation_def(rdef)
   522             self.add_relation_def(rdef)
   521             rdef = ybo.RelationDefinition(eschema.type, 'identity', eschema.type)
   523             rdef = ybo.RelationDefinition(eschema.type, 'identity', eschema.type,
       
   524                                           __permissions__=RO_REL_PERMS)
   522             self.add_relation_def(rdef)
   525             self.add_relation_def(rdef)
   523         self._eid_index[eschema.eid] = eschema
   526         self._eid_index[eschema.eid] = eschema
   524         return eschema
   527         return eschema
   525 
   528 
   526     def add_relation_type(self, rdef):
   529     def add_relation_type(self, rdef):