Commit 03046a8e authored by Simon Chabot's avatar Simon Chabot
Browse files

revert: backed out changeset bcb633bd791d, don’t give event to notify_on_commit

Notification are done using Operation, and Operation do not have a `event`
attribute, because they can be used for several event.

Moreover, this commit (bcb633bd791d) changed the prototype of the
`notify_on_commit` without giving the right event to the Operation (which is a
singleton)

--HG--
branch : 3.31
parent 8b2537520e18
...@@ -27,7 +27,7 @@ from cubicweb.server import hook ...@@ -27,7 +27,7 @@ from cubicweb.server import hook
from cubicweb.sobjects.supervising import SupervisionMailOp from cubicweb.sobjects.supervising import SupervisionMailOp
def notify_on_commit(cnx, view, event, viewargs=None): def notify_on_commit(cnx, view, viewargs=None):
"""register a notification view (see """register a notification view (see
:class:`~cubicweb.sobjects.notification.NotificationView`) to be sent at :class:`~cubicweb.sobjects.notification.NotificationView`) to be sent at
post-commit time, ie only if the transaction has succeeded. post-commit time, ie only if the transaction has succeeded.
...@@ -37,7 +37,7 @@ def notify_on_commit(cnx, view, event, viewargs=None): ...@@ -37,7 +37,7 @@ def notify_on_commit(cnx, view, event, viewargs=None):
""" """
if viewargs is None: if viewargs is None:
viewargs = {} viewargs = {}
notif_op = _RenderAndSendNotificationOp.get_instance(cnx, event=event) notif_op = _RenderAndSendNotificationOp.get_instance(cnx)
notif_op.add_data((view, viewargs)) notif_op.add_data((view, viewargs))
...@@ -114,7 +114,7 @@ class StatusChangeHook(NotificationHook): ...@@ -114,7 +114,7 @@ class StatusChangeHook(NotificationHook):
viewargs = {'comment': comment, viewargs = {'comment': comment,
'previous_state': entity.previous_state.name, 'previous_state': entity.previous_state.name,
'current_state': entity.new_state.name} 'current_state': entity.new_state.name}
notify_on_commit(self._cw, view, event=self.event, viewargs=viewargs) notify_on_commit(self._cw, view, viewargs=viewargs)
class RelationChangeHook(NotificationHook): class RelationChangeHook(NotificationHook):
__regid__ = 'notifyrelationchange' __regid__ = 'notifyrelationchange'
...@@ -130,7 +130,7 @@ class RelationChangeHook(NotificationHook): ...@@ -130,7 +130,7 @@ class RelationChangeHook(NotificationHook):
rset=rset, row=0) rset=rset, row=0)
if view is None: if view is None:
return return
notify_on_commit(self._cw, view, event=self.event) notify_on_commit(self._cw, view)
class EntityChangeHook(NotificationHook): class EntityChangeHook(NotificationHook):
...@@ -145,7 +145,7 @@ class EntityChangeHook(NotificationHook): ...@@ -145,7 +145,7 @@ class EntityChangeHook(NotificationHook):
view = self.select_view('notif_%s' % self.event, rset=rset, row=0) view = self.select_view('notif_%s' % self.event, rset=rset, row=0)
if view is None: if view is None:
return return
notify_on_commit(self._cw, view, event=self.event) notify_on_commit(self._cw, view)
class EntityUpdatedNotificationOp(hook.SingleLastOperation): class EntityUpdatedNotificationOp(hook.SingleLastOperation):
...@@ -158,7 +158,7 @@ class EntityUpdatedNotificationOp(hook.SingleLastOperation): ...@@ -158,7 +158,7 @@ class EntityUpdatedNotificationOp(hook.SingleLastOperation):
view = cnx.vreg['views'].select('notif_entity_updated', cnx, view = cnx.vreg['views'].select('notif_entity_updated', cnx,
rset=cnx.eid_rset(eid), rset=cnx.eid_rset(eid),
row=0) row=0)
notify_on_commit(self.cnx, view, event=self.event, notify_on_commit(self.cnx, view,
viewargs={'changes': cnx.transaction_data['changes'][eid]}) viewargs={'changes': cnx.transaction_data['changes'][eid]})
......
...@@ -17,8 +17,8 @@ notification: ...@@ -17,8 +17,8 @@ notification:
* write a hook for event that should trigger this notification, select the view * write a hook for event that should trigger this notification, select the view
(without rendering it), and give it to (without rendering it), and give it to
:func:`cubicweb.hooks.notification.notify_on_commit` with the event type as a :func:`cubicweb.hooks.notification.notify_on_commit` so that the notification
string so that the notification will be sent if the transaction succeed. will be sent if the transaction succeed.
.. XXX explain recipient finder and provide example .. XXX explain recipient finder and provide example
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment