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)
0
>>> INotificationRequest.providedBy(request)
True
>>> request = NotificationRequest()
>>> session = ISession(request)[SESSION_KEY]
>>> notifications = NotificationList()
>>> session['notifications'] = notifications
>>> notifications.append(Notification(0, 'Fnord'))
>>> [notification.message for notification in request.notifications]
['Fnord']

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
@property
def notifications(self):
Undocumented
API Documentation for Launchpad, generated by pydoctor at 2022-06-16 00:00:12.