# HG changeset patch # User Thierry Florac # Date 1505207614 -7200 # Node ID cba9ce0e9ee294e860d665df04306d9a47161ac6 # Parent 16f44247bcbf3fc5de9050aa63924306282c2cf6 Use adapters to get notifications contexts diff -r 16f44247bcbf -r cba9ce0e9ee2 src/pyams_notify/views/context.py --- a/src/pyams_notify/views/context.py Mon Sep 11 15:06:26 2017 +0200 +++ b/src/pyams_notify/views/context.py Tue Sep 12 11:13:34 2017 +0200 @@ -10,15 +10,16 @@ # FOR A PARTICULAR PURPOSE. # - __docformat__ = 'restructuredtext' # import standard library # import interfaces +from pyams_notify.interfaces import INotificationHandler # import packages +from pyams_notify.event import Notification from pyramid.view import view_config @@ -26,7 +27,12 @@ def NotificationsContextView(request): """Get context for notifications""" principal = request.principal + notification = Notification(request, + action='none', + category='notifications.query', + message='') + adapters = [name for name, adapter in request.registry.getAdapters((notification, ), INotificationHandler)] return {'principal': {'id': principal.id, 'title': principal.title, 'principals': tuple(request.effective_principals)}, - 'context': {'*': ['user.login', 'content.workflow']}} + 'context': {'*': adapters}}