[repo] misc cleanup stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 17 Aug 2009 11:06:43 +0200
branchstable
changeset 2873 51bcd8e8f65c
parent 2872 9d641d98cc86
child 2874 acdd8d8c2cff
[repo] misc cleanup
server/repository.py
--- a/server/repository.py	Mon Aug 17 11:06:02 2009 +0200
+++ b/server/repository.py	Mon Aug 17 11:06:43 2009 +0200
@@ -1039,9 +1039,9 @@
             # call hooks for inlined relations
             for attr, value in relations:
                 self.hm.call_hooks('before_add_relation', attr, session,
-                                    entity.eid, attr, value)
+                                   entity.eid, attr, value)
                 self.hm.call_hooks('after_add_relation', attr, session,
-                                    entity.eid, attr, value)
+                                   entity.eid, attr, value)
         return entity.eid
 
     def glob_update_entity(self, session, entity, edited_attributes):
@@ -1058,7 +1058,7 @@
         session.set_entity_cache(entity)
         only_inline_rels, need_fti_update = True, False
         relations = []
-        for attr in entity.keys():
+        for attr in edited_attributes:
             if attr == 'eid':
                 continue
             rschema = eschema.subject_relation(attr)
@@ -1068,8 +1068,8 @@
                 only_inline_rels = False
             else:
                 # inlined relation
-                previous_value = entity.related(attr)
-                if previous_value:
+                previous_value = entity.related(attr) or None
+                if previous_value is not None:
                     previous_value = previous_value[0][0] # got a result set
                     if previous_value == entity[attr]:
                         previous_value = None
@@ -1100,7 +1100,7 @@
             for attr, value, prevvalue in relations:
                 # if the relation is already cached, update existant cache
                 relcache = entity.relation_cached(attr, 'subject')
-                if prevvalue:
+                if prevvalue is not None:
                     self.hm.call_hooks('after_delete_relation', attr, session,
                                        entity.eid, attr, prevvalue)
                     if relcache is not None: