def __init__(self, impl, number, clsname, context): self._type = EventType.TYPES[number] self._clsname = clsname self._context = context # Do all this messing around to avoid duplicate wrappers if issubclass(type(context), Delivery): self._delivery = context else: self._delivery = Delivery.wrap(pn_event_delivery(impl)) if self._delivery: self._link = self._delivery.link elif issubclass(type(context), Link): self._link = context else: self._link = Link.wrap(pn_event_link(impl)) if self._link: self._session = self._link.session elif issubclass(type(context), Session): self._session = context else: self._session = Session.wrap(pn_event_session(impl)) if self._session: self._connection = self._session.connection elif issubclass(type(context), Connection): self._connection = context else: self._connection = Connection.wrap(pn_event_connection(impl)) if issubclass(type(context), Transport): self._transport = context else: self._transport = Transport.wrap(pn_event_transport(impl))
def session(self): """Returns the session associated with the event, or null if none is associated with it.""" return Session.wrap(pn_event_session(self._impl))