B [supervising] ignore updated event for entities created in the same transaction
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 03 Aug 2009 09:37:13 +0200
changeset 2649 5d4a943695d1
parent 2648 4ae7d02ce063
child 2650 18aec79ec3a3
B [supervising] ignore updated event for entities created in the same transaction
sobjects/supervising.py
--- a/sobjects/supervising.py	Mon Aug 03 09:24:08 2009 +0200
+++ b/sobjects/supervising.py	Mon Aug 03 09:37:13 2009 +0200
@@ -31,12 +31,16 @@
             SupervisionMailOp(session)
 
     def _call(self, *args):
-        if self._event() == 'update_entity' and args[0].e_schema == 'CWUser':
-            updated = set(args[0].iterkeys())
-            if not (updated - frozenset(('eid', 'modification_date', 'last_login_time'))):
-                # don't record last_login_time update which are done
-                # automatically at login time
+        if self._event() == 'update_entity':
+            if args[0].eid in self.session.transaction_data.get('neweids', ()):
                 return False
+            if args[0].e_schema == 'CWUser':
+                updated = set(args[0].iterkeys())
+                if not (updated - frozenset(('eid', 'modification_date',
+                                             'last_login_time'))):
+                    # don't record last_login_time update which are done
+                    # automatically at login time
+                    return False
         self.session.transaction_data.setdefault('pendingchanges', []).append(
             (self._event(), args))
         return True