[Zope-CVS] CVS: Products/Scheduler - Scheduler.py:1.25

Shane Hathaway shane at zope.com
Sun Apr 4 15:57:54 EDT 2004


Update of /cvs-repository/Products/Scheduler
In directory cvs.zope.org:/tmp/cvs-serv16436

Modified Files:
	Scheduler.py 
Log Message:
Added manage_[un]subscribe to make it possible to minimally manage subscriptions TTW


=== Products/Scheduler/Scheduler.py 1.24 => 1.25 ===
--- Products/Scheduler/Scheduler.py:1.24	Wed Jul  9 21:42:57 2003
+++ Products/Scheduler/Scheduler.py	Sun Apr  4 15:57:46 2004
@@ -116,23 +116,35 @@
             return Filter(self.filter_data)
         return None
 
+    security.declarePrivate("manage_afterAdd")
     def manage_afterAdd(self, item, container):
-        event_service = getattr(self, self.event_service, None)
-        if event_service is not None:
-            # receive all time events
-            event_service.subscribe(self, ITimeEvent)
-            # receive schedule events that match our id
-            event_service.subscribe(self, IScheduledEvent,
-                                    filter=self.getFilter())
+        if hasattr(self, self.event_service):
+            self.manage_subscribe()
 
+    security.declarePrivate("manage_beforeDelete")
     def manage_beforeDelete(self, item, container):
-        event_service = getattr(self, self.event_service, None)
-        if event_service is not None:
-            # un-receive all time events
-            event_service.unsubscribe(self, ITimeEvent)
-            # un-receive schedule events that match our id
-            event_service.unsubscribe(self, IScheduledEvent,
-                                      filter=self.getFilter())
+        if hasattr(self, self.event_service):
+            self.manage_unsubscribe()
+
+    security.declareProtected(MGMT_SCREEN_PERM, "manage_subscribe")
+    def manage_subscribe(self):
+        """Add subscriptions to the event tool"""
+        event_service = getattr(self, self.event_service)
+        # receive all time events
+        event_service.subscribe(self, ITimeEvent)
+        # receive schedule events that match our id
+        event_service.subscribe(self, IScheduledEvent,
+                                filter=self.getFilter())
+
+    security.declareProtected(MGMT_SCREEN_PERM, "manage_unsubscribe")
+    def manage_unsubscribe(self):
+        """Remove subscriptions from the event tool"""
+        event_service = getattr(self, self.event_service)
+        # un-receive all time events
+        event_service.unsubscribe(self, ITimeEvent)
+        # un-receive schedule events that match our id
+        event_service.unsubscribe(self, IScheduledEvent,
+                                  filter=self.getFilter())
 
     security.declareProtected(NOTIFY_SCHEDULE_PERM, 'notify')
     def notify(self, event=None, max_tasks=None):




More information about the Zope-CVS mailing list