[Zope3-checkins] CVS: Zope3/src/zope/app/interfaces/services - configuration.py:1.4 interfaces.py:1.15

Guido van Rossum guido@python.org
Mon, 3 Mar 2003 18:16:41 -0500


Update of /cvs-repository/Zope3/src/zope/app/interfaces/services
In directory cvs.zope.org:/tmp/cvs-serv7820/src/zope/app/interfaces/services

Modified Files:
	configuration.py interfaces.py 
Log Message:
Merge from use-config-branch.  (A joint production by Jim, Tim and Guido.)

- Refactor the service creation and configuration code, making the UI
  for creating and configuring services much more pleasant.

- Add a new marker interface, IUseConfigurable, which is used to say
  that an object records dependencies between it and its
  configurations.  (This applies to other configurable objects besides
  services.)  Another marker interface, IAttributeUseConfigurable,
  says that these dependencies are stored as annotations.  And finally
  IUseConfiguration defines the actual interface for discussing these
  dependencies; implementing IUseConfigurable is a promise that such
  an adapter exists (and implementing IAttributeUseConfigurable is one
  way of making this promise come true :-).

- Add a new view tab for services, called "Configurations", which
  displays links to its configurations with summary information.  (Try
  it for the Events service, which has two configurations by default.)

- Add a new interface, ILocalService, which all local services must
  implement.  Also add ISimpleService, which extends ILocalService
  with IAttributeUseConfigurable.  All existing local service
  implementations implement this.

- Some miscellaneous cleanup (e.g. made the browser namespace the
  default namespace in zope/app/browser/services/configure.zcml).


=== Zope3/src/zope/app/interfaces/services/configuration.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/interfaces/services/configuration.py:1.3	Thu Dec 26 13:55:35 2002
+++ Zope3/src/zope/app/interfaces/services/configuration.py	Mon Mar  3 18:16:10 2003
@@ -20,6 +20,8 @@
 from zope.schema import Text, TextLine
 from zope.schema.interfaces import ITextLine
 from zope.app.security.permission import PermissionField
+from zope.app.interfaces.annotation import IAnnotatable
+from zope.app.interfaces.annotation import IAttributeAnnotatable
 
 Unregistered = u'Unregistered'
 Registered = u'Registered'
@@ -252,3 +254,35 @@
         an active configuration, and if so, returns its component.  Otherwise
         returns default.
         """
+
+class IUseConfigurable(IAnnotatable):
+    """A marker interface."""
+
+class IUseConfiguration(IUseConfigurable):
+    """An object that can keep track of its configured uses.
+
+    The object need not implement this functionality itself, but must at
+    least support doing so via an adapter.
+    """
+
+    def addUsage(location):
+        """Add a usage by location.
+
+        The location is the physical path to the configuration object that
+        configures the usage.
+        """
+    def removeUsage(location):
+        """Remove a usage by location.
+
+        The location is the physical path to the configuration object that
+        configures the usage.
+        """
+    def usages():
+        """Return a sequence of locations.
+
+        A location is a physical path to a configuration object that
+        configures a usage.
+        """
+
+class IAttributeUseConfigurable(IAttributeAnnotatable, IUseConfigurable):
+    """A marker interface."""


=== Zope3/src/zope/app/interfaces/services/interfaces.py 1.14 => 1.15 ===
--- Zope3/src/zope/app/interfaces/services/interfaces.py:1.14	Fri Feb 21 09:50:04 2003
+++ Zope3/src/zope/app/interfaces/services/interfaces.py	Mon Mar  3 18:16:10 2003
@@ -24,6 +24,27 @@
 from zope.app.services.field import ComponentPath
 from zope.component.interfaces import IPresentation
 from zope.app.interfaces.container import IDeleteNotifiable
+from zope.app.interfaces.services.configuration \
+     import IUseConfigurable, IAttributeUseConfigurable
+
+
+class ILocalService(IUseConfigurable):
+    """A local service isn't a local service if it doesn't implement this.
+
+    The contract of a local service includes collaboration with
+    services above it.  A local service should also implement
+    IUseConfigurable (which implies that it is adaptable to
+    IUseConfiguration).  Implementing ILocalService implies this.
+    """
+
+
+class ISimpleService(ILocalService, IAttributeUseConfigurable):
+    """Most local services should implement this instead of ILocalService.
+
+    It implies a specific way of implementing IUseConfigurable,
+    by subclassing IAttributeUseConfigurable.
+    """
+
 
 class IAdapterConfigurationInfo(Interface):