[source] small refactoring to avoid being doomed by a wrong assertion message on buggy storage raising attribute error stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 12 Apr 2010 15:15:00 +0200
branchstable
changeset 5217 08e7fa906cdb
parent 5215 b1327f19d23e
child 5218 aebd00a2d316
[source] small refactoring to avoid being doomed by a wrong assertion message on buggy storage raising attribute error
server/sources/native.py
--- a/server/sources/native.py	Mon Apr 12 15:11:23 2010 +0200
+++ b/server/sources/native.py	Mon Apr 12 15:15:00 2010 +0200
@@ -475,13 +475,15 @@
         etype = entity.__regid__
         for attr, storage in self._storages.get(etype, {}).items():
             try:
-                if attr in entity.edited_attributes:
+                edited = entity.edited_attributes
+            except AttributeError:
+                assert event == 'deleted'
+                getattr(storage, 'entity_deleted')(entity, attr)
+            else:
+                if attr in edited:
                     handler = getattr(storage, 'entity_%s' % event)
                     real_value = handler(entity, attr)
                     restore_values[attr] = real_value
-            except AttributeError:
-                assert event == 'deleted'
-                getattr(storage, 'entity_deleted')(entity, attr)
         try:
             yield # 2/ execute the source's instructions
         finally: