[source] small refactoring to avoid being doomed by a wrong assertion message on buggy storage raising attribute error
--- 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: