equal
deleted
inserted
replaced
25 from cubicweb.predicates import is_instance |
25 from cubicweb.predicates import is_instance |
26 from cubicweb.server import hook |
26 from cubicweb.server import hook |
27 from cubicweb.sobjects.supervising import SupervisionMailOp |
27 from cubicweb.sobjects.supervising import SupervisionMailOp |
28 |
28 |
29 class RenderAndSendNotificationView(hook.Operation): |
29 class RenderAndSendNotificationView(hook.Operation): |
30 """delay rendering of notification view until precommit""" |
30 """delay rendering of notification view until postcommit""" |
31 view = None # make pylint happy |
31 view = None # make pylint happy |
32 |
32 |
33 def postcommit_event(self): |
33 def postcommit_event(self): |
34 view = self.view |
34 view = self.view |
35 if view.cw_rset is not None and not view.cw_rset: |
35 if view.cw_rset is not None and not view.cw_rset: |
108 return |
108 return |
109 RenderAndSendNotificationView(self._cw, view=view) |
109 RenderAndSendNotificationView(self._cw, view=view) |
110 |
110 |
111 |
111 |
112 class EntityUpdatedNotificationOp(hook.SingleLastOperation): |
112 class EntityUpdatedNotificationOp(hook.SingleLastOperation): |
|
113 """scrap all changed entity to prepare a Notification Operation for them""" |
113 |
114 |
114 def precommit_event(self): |
115 def precommit_event(self): |
|
116 # precommit event that creates postcommit operation |
115 session = self.session |
117 session = self.session |
116 for eid in session.transaction_data['changes']: |
118 for eid in session.transaction_data['changes']: |
117 view = session.vreg['views'].select('notif_entity_updated', session, |
119 view = session.vreg['views'].select('notif_entity_updated', session, |
118 rset=session.eid_rset(eid), |
120 rset=session.eid_rset(eid), |
119 row=0) |
121 row=0) |