hooks/syncschema.py
branchstable
changeset 4948 5774491a1421
parent 4928 cbca73dc9753
child 4951 7dc54e12c606
equal deleted inserted replaced
4947:c3ded0287295 4948:5774491a1421
   187         # every schema operation is triggering a schema update
   187         # every schema operation is triggering a schema update
   188         MemSchemaNotifyChanges(session)
   188         MemSchemaNotifyChanges(session)
   189 
   189 
   190     def prepare_constraints(self, rdef):
   190     def prepare_constraints(self, rdef):
   191         # if constraints is already a list, reuse it (we're updating multiple
   191         # if constraints is already a list, reuse it (we're updating multiple
   192         # constraints of the same rdef in the same transactions
   192         # constraints of the same rdef in the same transactions)
   193         if not isinstance(rdef.constraints, list):
   193         if not isinstance(rdef.constraints, list):
   194             rdef.constraints = list(rdef.constraints)
   194             rdef.constraints = list(rdef.constraints)
   195         self.constraints = rdef.constraints
   195         self.constraints = rdef.constraints
   196 
   196 
   197 
   197 
   665         if self.session.added_in_transaction(rdef.eid):
   665         if self.session.added_in_transaction(rdef.eid):
   666             self.cancelled = True
   666             self.cancelled = True
   667             return
   667             return
   668         rdef = self.session.vreg.schema.schema_by_eid(rdef.eid)
   668         rdef = self.session.vreg.schema.schema_by_eid(rdef.eid)
   669         self.prepare_constraints(rdef)
   669         self.prepare_constraints(rdef)
   670         subjtype, rtype, objtype = rdef.as_triple()
       
   671         cstrtype = self.entity.type
   670         cstrtype = self.entity.type
   672         self.cstr = rtype.rdef(subjtype, objtype).constraint_by_type(cstrtype)
   671         self.cstr = rdef.constraint_by_type(cstrtype)
   673         self.newcstr = CONSTRAINTS[cstrtype].deserialize(self.entity.value)
   672         self.newcstr = CONSTRAINTS[cstrtype].deserialize(self.entity.value)
   674         self.newcstr.eid = self.entity.eid
   673         self.newcstr.eid = self.entity.eid
   675 
   674 
   676     def commit_event(self):
   675     def commit_event(self):
   677         if self.cancelled:
   676         if self.cancelled: