[source storage] on deletion, entity has no edited_attributes stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 25 Mar 2010 13:46:55 +0100
branchstable
changeset 5011 57c4c6399b44
parent 5010 b2c5aee8ca3f
child 5012 9c4ea944ecf9
[source storage] on deletion, entity has no edited_attributes
server/sources/native.py
--- a/server/sources/native.py	Thu Mar 25 13:44:24 2010 +0100
+++ b/server/sources/native.py	Thu Mar 25 13:46:55 2010 +0100
@@ -428,10 +428,14 @@
         orig_values = {}
         etype = entity.__regid__
         for attr, storage in self._storages.get(etype, {}).items():
-            if attr in entity.edited_attributes:
-                orig_values[attr] = entity[attr]
-                handler = getattr(storage, 'entity_%s' % event)
-                handler(entity, attr)
+            try:
+                if attr in entity.edited_attributes:
+                    orig_values[attr] = entity[attr]
+                    handler = getattr(storage, 'entity_%s' % event)
+                    handler(entity, attr)
+            except AttributeError:
+                assert event == 'deleted'
+                getattr(storage, 'entity_deleted')(entity, attr)
         yield # 2/ execute the source's instructions
         # 3/ restore original values
         for attr, value in orig_values.items():