[mail] drop hijack_user usage
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Thu, 25 Apr 2013 12:24:26 +0200
changeset 8933 ac76925268a3
parent 8932 4ae4242bceb1
child 8934 48a6e6b88b16
[mail] drop hijack_user usage The transaction is now commited before notification. We can create a new session directly and drop `hijack_user` usage. This prepare #2781782
sobjects/notification.py
--- a/sobjects/notification.py	Thu Apr 25 13:35:02 2013 +0200
+++ b/sobjects/notification.py	Thu Apr 25 12:24:26 2013 +0200
@@ -30,6 +30,7 @@
 from cubicweb.view import Component, EntityView
 from cubicweb.server.hook import SendMailOp
 from cubicweb.mail import construct_message_id, format_mail
+from cubicweb.server.session import Session
 
 
 class RecipientsFinder(Component):
@@ -118,7 +119,7 @@
         for something in recipients:
             if isinstance(something, Entity):
                 # hi-jack self._cw to get a session for the returned user
-                self._cw = self._cw.hijack_user(something)
+                self._cw = Session(self._cw.repo, something)
                 emailaddr = something.cw_adapt_to('IEmailable').get_email()
             else:
                 emailaddr, lang = something