l.s.w.n.NotificationRequest : class documentation

Part of lp.services.webapp.notifications View In Hierarchy

Known subclasses: lp.services.webapp.servers.LaunchpadBrowserRequest

NotificationRequest extracts notifications to display to the user from the request and session

It is designed to be mixed in with an IBrowserRequest

By default, there are no notifications

>>> request = NotificationRequest()
>>> len(request.notifications)
>>> INotificationRequest.providedBy(request)
>>> request = NotificationRequest()
>>> session = ISession(request)[SESSION_KEY]
>>> notifications = NotificationList()
>>> session['notifications'] = notifications
>>> notifications.append(Notification(0, 'Fnord'))
>>> [notification.message for notification in request.notifications]

Note that NotificationRequest.notifications also returns any notifications that have been added so far in this request, making it the single source you need to interogate to display notifications to the user.

>>> response = INotificationResponse(request)
>>> response.addNotification('Aargh')
>>> [notification.message for notification in request.notifications]
['Fnord', u'Aargh']
Method notifications Undocumented
def notifications(self):
API Documentation for Launchpad, generated by pydoctor at 2020-09-29 00:00:05.