[Checkins] SVN: zc.notification/trunk/src/zc/notification/ make
getting annotations use context
Gary Poster
gary at zope.com
Wed Jan 17 15:13:12 EST 2007
Log message for revision 72073:
make getting annotations use context
Changed:
U zc.notification/trunk/src/zc/notification/interfaces.py
U zc.notification/trunk/src/zc/notification/notification.py
-=-
Modified: zc.notification/trunk/src/zc/notification/interfaces.py
===================================================================
--- zc.notification/trunk/src/zc/notification/interfaces.py 2007-01-17 19:54:39 UTC (rev 72072)
+++ zc.notification/trunk/src/zc/notification/interfaces.py 2007-01-17 20:13:12 UTC (rev 72073)
@@ -137,12 +137,12 @@
"""
- def setNotifierMethod(principal_id, method):
+ def setNotifierMethod(principal_id, method, context=None):
"""Set the preferred notifier method for `principal_id`.
"""
- def getNotifierMethod(principal_id):
+ def getNotifierMethod(principal_id, context=None):
"""Return the preferred notifier method for `principal_id`.
"""
Modified: zc.notification/trunk/src/zc/notification/notification.py
===================================================================
--- zc.notification/trunk/src/zc/notification/notification.py 2007-01-17 19:54:39 UTC (rev 72072)
+++ zc.notification/trunk/src/zc/notification/notification.py 2007-01-17 20:13:12 UTC (rev 72073)
@@ -164,16 +164,17 @@
# principal_id --> Set([notification names])
self._registrations = BTrees.OOBTree.OOBTree()
- def get_annotations(self, principal_id):
- utility = zope.component.getUtility(IPrincipalAnnotationUtility)
+ def get_annotations(self, principal_id, context=None):
+ utility = zope.component.getUtility(IPrincipalAnnotationUtility,
+ context=context)
return utility.getAnnotationsById(principal_id)
- def setNotifierMethod(self, principal_id, method):
- annotations = self.get_annotations(principal_id)
+ def setNotifierMethod(self, principal_id, method, context=None):
+ annotations = self.get_annotations(principal_id, context)
annotations[PREFERRED_METHOD_ANNOTATION_KEY] = method
- def getNotifierMethod(self, principal_id):
- annotations = self.get_annotations(principal_id)
+ def getNotifierMethod(self, principal_id, context=None):
+ annotations = self.get_annotations(principal_id, context)
return annotations.get(PREFERRED_METHOD_ANNOTATION_KEY, "")
def setRegistrations(self, principal_id, names):
@@ -212,7 +213,8 @@
set(self._notifications.get(notification.name, ())))
for id in ids:
- method = self.getNotifierMethod(id)
+ annotations = self.get_annotations(id, context)
+ method = annotations.get(PREFERRED_METHOD_ANNOTATION_KEY, "")
notifier = None
if method:
notifier = zope.component.queryUtility(
@@ -224,4 +226,4 @@
zc.notification.interfaces.INotifier,
context=context)
notifier.send(
- notification, id, self.get_annotations(id), context)
+ notification, id, annotations, context)
More information about the Checkins
mailing list