[CalendarServer-changes] [2693] CalendarServer/trunk/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Fri Jul 11 12:02:35 PDT 2008


Revision: 2693
          http://trac.macosforge.org/projects/calendarserver/changeset/2693
Author:   wsanchez at apple.com
Date:     2008-07-11 12:02:35 -0700 (Fri, 11 Jul 2008)
Log Message:
-----------
Make reactor argument to NotificationClient optional.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/notify.py
    CalendarServer/trunk/twistedcaldav/tap.py
    CalendarServer/trunk/twistedcaldav/test/test_notify.py

Modified: CalendarServer/trunk/twistedcaldav/notify.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/notify.py	2008-07-11 18:50:00 UTC (rev 2692)
+++ CalendarServer/trunk/twistedcaldav/notify.py	2008-07-11 19:02:35 UTC (rev 2693)
@@ -158,14 +158,17 @@
     startup.
     """
 
-    def __init__(self, reactor, host, port):
+    def __init__(self, host, port, reactor=None):
         self.factory = None
-        self.reactor = reactor
         self.host = host
         self.port = port
         self.observers = set()
         self.queued = set()
 
+        if reactor is None:
+            from twisted.internet import reactor
+        self.reactor = reactor
+
     def send(self, uri):
         if self.factory is None:
             self.factory = NotificationClientFactory(self)
@@ -197,9 +200,9 @@
 
 _notificationClient = None
 
-def installNotificationClient(reactor, host, port, klass=NotificationClient):
+def installNotificationClient(host, port, klass=NotificationClient, reactor=None):
     global _notificationClient
-    _notificationClient = klass(reactor, host, port)
+    _notificationClient = klass(host, port, reactor=reactor)
 
 def getNotificationClient():
     return _notificationClient

Modified: CalendarServer/trunk/twistedcaldav/tap.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/tap.py	2008-07-11 18:50:00 UTC (rev 2692)
+++ CalendarServer/trunk/twistedcaldav/tap.py	2008-07-11 19:02:35 UTC (rev 2693)
@@ -495,9 +495,11 @@
         # Configure NotificationClient
         #
         if config.Notifications["Enabled"]:
-            installNotificationClient(reactor,
+            from twisted.internet import reactor
+            installNotificationClient(
                 config.Notifications["InternalNotificationHost"],
-                config.Notifications["InternalNotificationPort"])
+                config.Notifications["InternalNotificationPort"],
+            )
 
         #
         # Setup Resource hierarchy

Modified: CalendarServer/trunk/twistedcaldav/test/test_notify.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_notify.py	2008-07-11 18:50:00 UTC (rev 2692)
+++ CalendarServer/trunk/twistedcaldav/test/test_notify.py	2008-07-11 19:02:35 UTC (rev 2693)
@@ -33,8 +33,8 @@
     def test_installNoficationClient(self):
         self.assertEquals(getNotificationClient(), None)
         self.clock = Clock()
-        installNotificationClient(self.clock, None, None,
-            klass=StubNotificationClient)
+        installNotificationClient(None, None,
+            klass=StubNotificationClient, reactor=self.clock)
         notificationClient = getNotificationClient()
         self.assertNotEquals(notificationClient, None)
 
@@ -46,7 +46,7 @@
 class NotificationClientFactoryTests(TestCase):
 
     def setUp(self):
-        self.client = StubNotificationClient(None, None, None)
+        self.client = StubNotificationClient(None, None)
         self.factory = NotificationClientFactory(self.client)
         self.factory.protocol = StubNotificationClientProtocol
 
@@ -64,7 +64,7 @@
 
 class StubNotificationClient(object):
 
-    def __init__(self, reactor, host, port):
+    def __init__(self, host, port, reactor=None):
         self.lines = []
         self.observers = set()
 
@@ -100,7 +100,7 @@
 class NotificationClientTests(TestCase):
 
     def setUp(self):
-        self.client = NotificationClient(Clock(), None, None)
+        self.client = NotificationClient(None, None, reactor=Clock())
         self.client.factory = StubNotificationClientFactory()
 
     def test_sendWhileNotConnected(self):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080711/8c06c3dd/attachment-0001.html 


More information about the calendarserver-changes mailing list