diff idavoll/backend.py @ 2:9701df89c534

First take at notifications
author Ralph Meijer <ralphm@ik.nu>
date Fri, 25 Jun 2004 20:31:14 +0000
parents 4cc41776b7d7
children 05a5d412e1b1
line wrap: on
line diff
--- a/idavoll/backend.py	Wed Jun 23 14:31:49 2004 +0000
+++ b/idavoll/backend.py	Fri Jun 25 20:31:14 2004 +0000
@@ -5,6 +5,9 @@
 class IBackendService(components.Interface):
 	""" Interface to a backend service of a pubsub service """
 
+	def do_publish(self, node, publisher, item):
+		""" Returns a deferred that returns """
+
 class BackendException(Exception):
 	def __init__(self, msg = ''):
 		self.msg = msg
@@ -26,8 +29,8 @@
 
 	def __init__(self):
 		self.nodes = {"ralphm/test": 'test'}
-		self.subscribers = {"ralphm/test": ["ralphm@ik.nu", "intosi@ik.nu"] }
-		self.affiliations = {"ralphm/test": { "ralphm@ik.nu": "owner", "ralphm@se-135.se.wtb.tue.nl": 'publisher' } }
+		self.subscribers = {"ralphm/test": ["ralphm@ik.nu", "ralphm@doe.ik.nu"] }
+		self.affiliations = {"ralphm/test": { "ralphm@ik.nu": "owner", "ralphm@se-135.se.wtb.tue.nl": 'publisher', 'ralphm@doe.ik.nu': 'publisher' } }
 
 	def do_publish(self, node, publisher, item):
 		try:
@@ -42,12 +45,21 @@
 					raise NotAuthorized
 			except KeyError:
 				raise NotAuthorized()
+
 			print "publish by %s to %s" % (publisher, node)
+
+			recipients = self.get_subscribers(node)
+			recipients.addCallback(self.magic_filter, node, item)
+			recipients.addCallback(self.pubsub_service.do_notification, node, item)
+
 			return defer.succeed(result)
 		except:
 			f = failure.Failure()
 			return defer.fail(f)
 
+	def magic_filter(self, subscribers, node, item):
+		return subscribers
+
 	def get_subscribers(self, node):
 		d = defer.Deferred()
 		try: