[Zope-CVS] CVS: Products/Scheduler - Scheduler.py:1.8 __init__.py:1.3

Tres Seaver tseaver@zope.com
Sun, 29 Sep 2002 16:50:05 -0400


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

Modified Files:
	Scheduler.py __init__.py 
Log Message:


  - __init__.py:
  
    o Move interfaces into a subpackage, and export from product scope.

      e.g., instead of:

        from Products.Scheduler.IScheduler import IScheduledEvent

      use:

        from Products.Scheduler import IScheduledEvent

      This avoids name clashes between the module and the event, and
      hides the physical distribution of interfaces across modules.

    o Import interfaces first, to make cycles harmless.

  - Scheduler:

    o Rearrange imports into "canonical" order (default Python,
      then generic Zope, then products, etc.)

    o Import / use unqualified names for interfaces.


=== Products/Scheduler/Scheduler.py 1.7 => 1.8 ===
--- Products/Scheduler/Scheduler.py:1.7	Wed Sep 25 08:48:00 2002
+++ Products/Scheduler/Scheduler.py	Sun Sep 29 16:50:05 2002
@@ -15,25 +15,32 @@
 
 $Id$
 """
-import IScheduler
-from OFS.SimpleItem import SimpleItem
-from OFS.PropertyManager import PropertyManager
-from AccessControl import ClassSecurityInfo
-from SchedulerPermissions import *
-from Products.PageTemplates.PageTemplateFile import PageTemplateFile
-from Products.Event.ISubscriptionAware import ISubscriptionAware
-from Products.Event.ISubscriber import ISubscriber
-from Persistence import Persistent
-from ExtensionClass import Base
-import Acquisition
-from Acquisition import aq_base
-import Globals
 import os, time, sys
 from types import FloatType, IntType
-import ZODB
+
+import Globals
 from BTrees import IOBTree
+from Persistence import Persistent
+from ExtensionClass import Base
+from Acquisition import Implicit
+from Acquisition import aq_base
+from AccessControl import ClassSecurityInfo
+
+from OFS.SimpleItem import SimpleItem
+from OFS.PropertyManager import PropertyManager
 from ZPublisher.mapply import mapply
 from ZPublisher.Publish import call_object, missing_name, dont_publish_class
+
+from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+from Products.Event.ISubscriptionAware import ISubscriptionAware
+from Products.Event.ISubscriber import ISubscriber
+
+from Products.Scheduler import IScheduler
+from Products.Scheduler import IScheduledEvent
+from Products.Scheduler import IDescheduledEvent
+from Products.Scheduler import ITimeEvent
+from SchedulerPermissions import *
+
 from zLOG import LOG, PROBLEM, ERROR, BLATHER
 
 __version__ = "$Revision$"[11:-2]
@@ -65,7 +72,7 @@
     security.setPermissionDefault(VIEW_SCHEDULE_PERM, ['Manager'])
     security.setPermissionDefault(NOTIFY_SCHEDULE_PERM, ['Manager'])
         
-    __implements__ = (IScheduler.IScheduler, ISubscriptionAware, ISubscriber)
+    __implements__ = (IScheduler, ISubscriptionAware, ISubscriber)
 
     def __init__(self, id, title='', filter_data='',
                  event_service='portal_events'):
@@ -112,18 +119,18 @@
         event_service = getattr(self, self.event_service, None)
         if event_service is not None:
             # receive all time events
-            event_service.subscribe(self, IScheduler.ITimeEvent)
+            event_service.subscribe(self, ITimeEvent)
             # receive schedule events that match our id
-            event_service.subscribe(self, IScheduler.IScheduledEvent,
+            event_service.subscribe(self, IScheduledEvent,
                                     filter=self.getFilter())
 
     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, IScheduler.ITimeEvent)
+            event_service.unsubscribe(self, ITimeEvent)
             # un-receive schedule events that match our id
-            event_service.unsubscribe(self, IScheduler.IScheduledEvent,
+            event_service.unsubscribe(self, IScheduledEvent,
                                       filter=self.getFilter())
 
     security.declareProtected(NOTIFY_SCHEDULE_PERM, 'notify')
@@ -158,17 +165,17 @@
         elif (isinstance(event, IntType) or isinstance(event, FloatType)):
             # Check if event is an integer or a float.
             t = int(event)
-        elif IScheduler.ITimeEvent.isImplementedBy(event):
+        elif ITimeEvent.isImplementedBy(event):
             # Check if event is an object that implements the ITimeEvent
             # interface that we need to get a number time from
             t = int(event.getTime())
-        elif IScheduler.IScheduledEvent.isImplementedBy(event):
+        elif IScheduledEvent.isImplementedBy(event):
             # this is a schedule event, we want to schedule this event
             # with ourselves, but we don't want to actually perform
             # any tasks.
             self.schedule(event.getTime(), event)
             return
-        elif IScheduler.IDescheduledEvent.isImplementedBy(event):
+        elif IDescheduledEvent.isImplementedBy(event):
             # this is a deschedule event, we want to deschedule this event,
             # but we don't want to actually perform any tasks.
             self.deschedule(event.getTime())
@@ -211,7 +218,7 @@
             except TypeError:
                 next_time, next_task = None, None
             
-            if IScheduler.IScheduledEvent.isImplementedBy(next_task):
+            if IScheduledEvent.isImplementedBy(next_task):
                 self.schedule(next_time, next_task)
                 continue
 
@@ -305,13 +312,13 @@
        'www/manage_schedule_tasks',globals(),__name__='manage_schedule_tasks'
         )
 
-class Task(Acquisition.Implicit, Persistent):
+class Task(Implicit, Persistent):
 
     security = ClassSecurityInfo()
     security.declareObjectPublic()
     security.setDefaultAccess("allow")
 
-    __implements__ = IScheduler.IScheduledEvent
+    __implements__ = IScheduledEvent
 
     def __init__(self, description, when, path, interval=None, max_age=600,
                  max_retries=5, retry_backoff_time=60, filter_data=None):


=== Products/Scheduler/__init__.py 1.2 => 1.3 ===
--- Products/Scheduler/__init__.py:1.2	Sun Sep 29 15:34:26 2002
+++ Products/Scheduler/__init__.py	Sun Sep 29 16:50:05 2002
@@ -18,14 +18,12 @@
 
 __version__='$Revision$'[11:-2]
 
-import Scheduler, SchedulerPermissions
-
 from interfaces.IScheduler import IScheduler
 from interfaces.IScheduler import IScheduledEvent
 from interfaces.IScheduler import IDescheduledEvent
 from interfaces.IScheduler import ITimeEvent
 
-class ITimeEvent(Interface.Base):
+import Scheduler, SchedulerPermissions
 
 def initialize(context):
     context.registerClass(