notification: use viewargs for notif_entity_updated instead of transaction_data
authorJulien Cristau <julien.cristau@logilab.fr>
Thu, 13 Jun 2013 12:01:23 +0200
changeset 9006 e4ea8f9ffa11
parent 9005 63cf580accfc
child 9007 e27337dfec8c
notification: use viewargs for notif_entity_updated instead of transaction_data Now that notifications use separate sessions, they can't rely on the original transaction_data being around, so pass the data through view arguments instead, so the notification view knows what changed on updated entities. Closes #2936180
hooks/notification.py
sobjects/notification.py
--- a/hooks/notification.py	Thu Jun 13 12:03:59 2013 +0200
+++ b/hooks/notification.py	Thu Jun 13 12:01:23 2013 +0200
@@ -158,7 +158,8 @@
             view = session.vreg['views'].select('notif_entity_updated', session,
                                                 rset=session.eid_rset(eid),
                                                 row=0)
-            notify_on_commit(self.session, view)
+            notify_on_commit(self.session, view,
+                    viewargs={'changes': session.transaction_data['changes'][eid]})
 
 
 class EntityUpdateHook(NotificationHook):
--- a/sobjects/notification.py	Thu Jun 13 12:03:59 2013 +0200
+++ b/sobjects/notification.py	Thu Jun 13 12:01:23 2013 +0200
@@ -292,9 +292,8 @@
 url: %(url)s
 """
 
-    def context(self, **kwargs):
+    def context(self, changes=(), **kwargs):
         context = super(EntityUpdatedNotificationView, self).context(**kwargs)
-        changes = self._cw.transaction_data['changes'][self.cw_rset[0][0]]
         _ = self._cw._
         formatted_changes = []
         entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)