[storage] relies on event=='deleted' to detect "delete" event stable
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 31 Jul 2012 10:57:03 +0200
branchstable
changeset 8499 75abcdc94f4a
parent 8498 bd4addfb6fd5
child 8500 bfc1875ce9e3
[storage] relies on event=='deleted' to detect "delete" event When we delete a previously edited entity, it *will* have a cw_edited attribute even if the goal is to delete it. The function get an argument that explicitly contains the "delete" event. The code now uses that instead.
server/sources/native.py
--- a/server/sources/native.py	Tue Jul 31 11:19:11 2012 +0200
+++ b/server/sources/native.py	Tue Jul 31 10:57:03 2012 +0200
@@ -613,12 +613,10 @@
         etype = entities[0].__regid__
         for attr, storage in self._storages.get(etype, {}).items():
             for entity in entities:
-                try:
+                if event == 'deleted':
+                    storage.entity_deleted(entity, attr)
+                else:
                     edited = entity.cw_edited
-                except AttributeError:
-                    assert event == 'deleted'
-                    getattr(storage, 'entity_deleted')(entity, attr)
-                else:
                     if attr in edited:
                         handler = getattr(storage, 'entity_%s' % event)
                         to_restore = handler(entity, attr)