sobjects/notification.py
changeset 8933 ac76925268a3
parent 8932 4ae4242bceb1
child 9004 a3594bf2b6bf
equal deleted inserted replaced
8932:4ae4242bceb1 8933:ac76925268a3
    28 
    28 
    29 from cubicweb.entity import Entity
    29 from cubicweb.entity import Entity
    30 from cubicweb.view import Component, EntityView
    30 from cubicweb.view import Component, EntityView
    31 from cubicweb.server.hook import SendMailOp
    31 from cubicweb.server.hook import SendMailOp
    32 from cubicweb.mail import construct_message_id, format_mail
    32 from cubicweb.mail import construct_message_id, format_mail
       
    33 from cubicweb.server.session import Session
    33 
    34 
    34 
    35 
    35 class RecipientsFinder(Component):
    36 class RecipientsFinder(Component):
    36     """this component is responsible to find recipients of a notification
    37     """this component is responsible to find recipients of a notification
    37 
    38 
   116         self.user_data = req.user_data()
   117         self.user_data = req.user_data()
   117         origlang = req.lang
   118         origlang = req.lang
   118         for something in recipients:
   119         for something in recipients:
   119             if isinstance(something, Entity):
   120             if isinstance(something, Entity):
   120                 # hi-jack self._cw to get a session for the returned user
   121                 # hi-jack self._cw to get a session for the returned user
   121                 self._cw = self._cw.hijack_user(something)
   122                 self._cw = Session(self._cw.repo, something)
   122                 emailaddr = something.cw_adapt_to('IEmailable').get_email()
   123                 emailaddr = something.cw_adapt_to('IEmailable').get_email()
   123             else:
   124             else:
   124                 emailaddr, lang = something
   125                 emailaddr, lang = something
   125                 self._cw.set_language(lang)
   126                 self._cw.set_language(lang)
   126             # since the same view (eg self) may be called multiple time and we
   127             # since the same view (eg self) may be called multiple time and we