server/schemahooks.py
changeset 2599 79bd12769c55
parent 2476 1294a6bdf3bf
child 2617 89c62b855f2e
--- a/server/schemahooks.py	Fri Jul 31 23:33:05 2009 +0200
+++ b/server/schemahooks.py	Fri Jul 31 23:35:07 2009 +0200
@@ -371,12 +371,12 @@
     def precommit_event(self):
         session = self.session
         entity = self.entity
-        fromentity = entity.from_entity[0]
-        relationtype = entity.relation_type[0]
+        fromentity = entity.stype
+        relationtype = entity.rtype
         session.execute('SET X ordernum Y+1 WHERE X from_entity SE, SE eid %(se)s, X ordernum Y, X ordernum >= %(order)s, NOT X eid %(x)s',
                         {'x': entity.eid, 'se': fromentity.eid, 'order': entity.ordernum or 0})
         subj, rtype = str(fromentity.name), str(relationtype.name)
-        obj = str(entity.to_entity[0].name)
+        obj = str(entity.otype.name)
         # at this point default is a string or None, but we need a correctly
         # typed value
         default = entity.defaultval
@@ -444,12 +444,12 @@
     def precommit_event(self):
         session = self.session
         entity = self.entity
-        fromentity = entity.from_entity[0]
-        relationtype = entity.relation_type[0]
+        fromentity = entity.stype.name
+        relationtype = entity.rtype
         session.execute('SET X ordernum Y+1 WHERE X from_entity SE, SE eid %(se)s, X ordernum Y, X ordernum >= %(order)s, NOT X eid %(x)s',
                         {'x': entity.eid, 'se': fromentity.eid, 'order': entity.ordernum or 0})
         subj, rtype = str(fromentity.name), str(relationtype.name)
-        obj = str(entity.to_entity[0].name)
+        obj = str(entity.otype.name)
         card = entity.get('cardinality')
         rdef = RelationDefinition(subj, rtype, obj,
                                   cardinality=card,
@@ -586,8 +586,8 @@
 
 
 def after_update_erdef(session, entity):
-    desttype = entity.to_entity[0].name
-    rschema = session.repo.schema[entity.relation_type[0].name]
+    desttype = entity.otype.name
+    rschema = session.repo.schema[entity.rtype.name]
     newvalues = {}
     for prop in rschema.rproperty_defs(desttype):
         if prop == 'constraints':
@@ -597,7 +597,7 @@
         if prop in entity:
             newvalues[prop] = entity[prop]
     if newvalues:
-        subjtype = entity.from_entity[0].name
+        subjtype = entity.stype.name
         UpdateRelationDefOp(session, (subjtype, desttype),
                             rschema=rschema, values=newvalues)