cubicweb/sobjects/notification.py
changeset 12043 b8d2e6b9f548
parent 11913 4516c3956d46
child 12046 9056a41d91ba
equal deleted inserted replaced
12042:5e64a98572de 12043:b8d2e6b9f548
    30 
    30 
    31 from cubicweb.entity import Entity
    31 from cubicweb.entity import Entity
    32 from cubicweb.view import Component, EntityView
    32 from cubicweb.view import Component, EntityView
    33 from cubicweb.server.hook import SendMailOp
    33 from cubicweb.server.hook import SendMailOp
    34 from cubicweb.mail import construct_message_id, format_mail
    34 from cubicweb.mail import construct_message_id, format_mail
    35 from cubicweb.server.session import Session, InternalManager
    35 from cubicweb.server.session import Connection, InternalManager
    36 
    36 
    37 
    37 
    38 class RecipientsFinder(Component):
    38 class RecipientsFinder(Component):
    39     """this component is responsible to find recipients of a notification
    39     """this component is responsible to find recipients of a notification
    40 
    40 
   118                 user = InternalManager(lang=lang)
   118                 user = InternalManager(lang=lang)
   119             else:
   119             else:
   120                 emailaddr = something.cw_adapt_to('IEmailable').get_email()
   120                 emailaddr = something.cw_adapt_to('IEmailable').get_email()
   121                 user = something
   121                 user = something
   122             # hi-jack self._cw to get a session for the returned user
   122             # hi-jack self._cw to get a session for the returned user
   123             session = Session(user, self._cw.repo)
   123             with Connection(self._cw.repo, user) as cnx:
   124             with session.new_cnx() as cnx:
       
   125                 self._cw = cnx
   124                 self._cw = cnx
   126                 try:
   125                 try:
   127                     # since the same view (eg self) may be called multiple time and we
   126                     # since the same view (eg self) may be called multiple time and we
   128                     # need a fresh stream at each iteration, reset it explicitly
   127                     # need a fresh stream at each iteration, reset it explicitly
   129                     self.w = None
   128                     self.w = None