cleanup
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Sat, 01 Aug 2009 01:24:42 +0200
changeset 2624 c0b5b189190e
parent 2623 e1f34b77290b
child 2625 d6012db7b93e
cleanup
server/schemahooks.py
--- a/server/schemahooks.py	Sat Aug 01 01:24:03 2009 +0200
+++ b/server/schemahooks.py	Sat Aug 01 01:24:42 2009 +0200
@@ -372,10 +372,10 @@
         session = self.session
         entity = self.entity
         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)
+        subj = str(fromentity.name)
+        rtype = entity.rtype.name
         obj = str(entity.otype.name)
         # at this point default is a string or None, but we need a correctly
         # typed value
@@ -445,11 +445,14 @@
     def precommit_event(self):
         session = self.session
         entity = self.entity
-        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)
+        fromentity = entity.stype
+        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 = str(fromentity.name)
+        rtype = entity.rtype.name
         obj = str(entity.otype.name)
         card = entity.get('cardinality')
         rdef = RelationDefinition(subj, rtype, obj,