[Zope3-checkins] SVN: Zope3/branches/srichter-blow-services/src/zope/app/component/ Fixed zope.app.component.interface to be all uptodate. Also started

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri Jan 7 09:37:26 EST 2005


Log message for revision 28761:
  Fixed zope.app.component.interface to be all uptodate. Also started 
  fixing up the directives.
  

Changed:
  U   Zope3/branches/srichter-blow-services/src/zope/app/component/README.txt
  U   Zope3/branches/srichter-blow-services/src/zope/app/component/interface.py
  U   Zope3/branches/srichter-blow-services/src/zope/app/component/metaconfigure.py

-=-
Modified: Zope3/branches/srichter-blow-services/src/zope/app/component/README.txt
===================================================================
--- Zope3/branches/srichter-blow-services/src/zope/app/component/README.txt	2005-01-07 14:10:12 UTC (rev 28760)
+++ Zope3/branches/srichter-blow-services/src/zope/app/component/README.txt	2005-01-07 14:37:25 UTC (rev 28761)
@@ -126,4 +126,4 @@
 or you can simply use the `queryNextUtility` and specify a default:
 
   >>> component.queryNextUtility(gutil, IMyUtility, 'myutil', 'default')
-  'default'
\ No newline at end of file
+  'default'

Modified: Zope3/branches/srichter-blow-services/src/zope/app/component/interface.py
===================================================================
--- Zope3/branches/srichter-blow-services/src/zope/app/component/interface.py	2005-01-07 14:10:12 UTC (rev 28760)
+++ Zope3/branches/srichter-blow-services/src/zope/app/component/interface.py	2005-01-07 14:37:25 UTC (rev 28761)
@@ -16,35 +16,36 @@
 $Id$
 """
 __docformat__ = 'restructuredtext'
-
+from types import ClassType
 from zope.component.exceptions import ComponentLookupError
 from zope.interface import directlyProvides
 from zope.interface.interfaces import IInterface
-from types import ClassType
 from zope.app import zapi
 
 def provideInterface(id, interface, iface_type=None, info=''):
-    """register Interface with utility service
+    """register Interface with global site manager as utility
 
-    >>> from zope.app.tests.placelesssetup import setUp, tearDown
-    >>> setUp()
-    >>> utilities = zapi.getGlobalService(zapi.servicenames.Utilities)
+    >>> from zope.app.testing import placelesssetup
+    >>> placelesssetup.setUp()
+    >>> gsm = zapi.getGlobalSiteManager()
+
     >>> from zope.interface import Interface
     >>> from zope.interface.interfaces import IInterface
     >>> from zope.app.content.interfaces import IContentType
+
     >>> class I(Interface):
     ...     pass
     >>> IInterface.providedBy(I)
     True
     >>> IContentType.providedBy(I)
     False
-    >>> interfaces = utilities.getUtilitiesFor(IContentType)
+    >>> interfaces = gsm.getUtilitiesFor(IContentType)
     >>> list(interfaces)
     []
     >>> provideInterface('', I, IContentType)
     >>> IContentType.providedBy(I)
     True
-    >>> interfaces = list(utilities.getUtilitiesFor(IContentType))
+    >>> interfaces = list(gsm.getUtilitiesFor(IContentType))
     >>> [name for (name, iface) in interfaces]
     [u'zope.app.component.interface.I']
     >>> [iface.__name__ for (name, iface) in interfaces]
@@ -56,13 +57,12 @@
     True
     >>> IContentType.providedBy(I1)
     False
-    >>> interfaces = list(utilities.getUtilitiesFor(IContentType))
+    >>> interfaces = list(gsm.getUtilitiesFor(IContentType))
     >>> [name for (name, iface) in interfaces]
     [u'zope.app.component.interface.I']
     >>> [iface.__name__ for (name, iface) in interfaces]
     ['I']
-    >>> tearDown()
-    
+    >>> placelesssetup.tearDown()
     """
     if not id:
         id = "%s.%s" % (interface.__module__, interface.__name__)
@@ -79,19 +79,19 @@
     else:
         iface_type = IInterface
         
-    utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)
-    utilityService.provideUtility(iface_type, interface, id, info)
+    gsm = zapi.getGlobalSiteManager()
+    gsm.provideUtility(iface_type, interface, id, info)
 
 
-
 def getInterface(context, id):
     """return interface or ComponentLookupError
 
-    >>> from zope.app.tests.placelesssetup import setUp, tearDown
-    >>> setUp()
-    >>> utilities = zapi.getGlobalService(zapi.servicenames.Utilities)
+    >>> from zope.app.testing import placelesssetup
+    >>> placelesssetup.setUp()
+
     >>> from zope.interface import Interface
     >>> from zope.app.content.interfaces import IContentType
+
     >>> class I4(Interface):
     ...     pass
     >>> IInterface.providedBy(I4)
@@ -109,24 +109,25 @@
                 """ 'zope.app.component.interface.I4')
     >>> iface.__name__
     'I4'
-    >>> tearDown()
-    
+    >>> placelesssetup.tearDown()    
     """
     iface = queryInterface(id, None)
     if iface is None:
         raise ComponentLookupError(id)
     return iface
 
+
 def queryInterface(id, default=None):
     """return interface or ``None``
 
-    >>> from zope.app.tests.placelesssetup import setUp, tearDown
-    >>> tearDown()
-    >>> setUp()
-    >>> utilities = zapi.getGlobalService(zapi.servicenames.Utilities)
+    >>> from zope.app.testing import placelesssetup
+    >>> placelesssetup.tearDown()
+    >>> placelesssetup.setUp()
+
     >>> from zope.interface import Interface
     >>> from zope.interface.interfaces import IInterface
     >>> from zope.app.content.interfaces import IContentType
+
     >>> class I3(Interface):
     ...     pass
     >>> IInterface.providedBy(I3)
@@ -141,21 +142,21 @@
     >>> iface = queryInterface('zope.app.component.interface.I3')
     >>> iface.__name__
     'I3'
-    >>> tearDown()
-    
+    >>> placelesssetup.tearDown()
     """
-    
     return zapi.queryUtility(IInterface, id, default)
 
+
 def searchInterface(context, search_string=None, base=None):
     """Interfaces search
 
-    >>> from zope.app.tests.placelesssetup import setUp, tearDown
-    >>> setUp()
-    >>> utilities = zapi.getGlobalService(zapi.servicenames.Utilities)
+    >>> from zope.app.testing import placelesssetup
+    >>> placelesssetup.setUp()
+
     >>> from zope.interface import Interface
     >>> from zope.interface.interfaces import IInterface
     >>> from zope.app.content.interfaces import IContentType
+
     >>> class I5(Interface):
     ...     pass
     >>> IInterface.providedBy(I5)
@@ -167,14 +168,11 @@
     >>> provideInterface('', I5, IContentType)
     >>> IContentType.providedBy(I5)
     True
-    >>> iface = searchInterface(None,
-    ...                        'zope.app.component.interface.I5')
+    >>> iface = searchInterface(None, 'zope.app.component.interface.I5')
     >>> iface[0].__name__
     'I5'
-    >>> tearDown()
-
+    >>> placelesssetup.tearDown()
     """
-
     return [iface_util[1]
             for iface_util in
             searchInterfaceUtilities(context, search_string, base)]
@@ -183,12 +181,13 @@
 def searchInterfaceIds(context, search_string=None, base=None):
     """Interfaces search
 
-    >>> from zope.app.tests.placelesssetup import setUp, tearDown
-    >>> setUp()
-    >>> utilities = zapi.getGlobalService(zapi.servicenames.Utilities)
+    >>> from zope.app.testing import placelesssetup
+    >>> placelesssetup.setUp()
+
     >>> from zope.interface import Interface
     >>> from zope.interface.interfaces import IInterface
     >>> from zope.app.content.interfaces import IContentType
+
     >>> class I5(Interface):
     ...     pass
     >>> IInterface.providedBy(I5)
@@ -204,18 +203,16 @@
     ...                        'zope.app.component.interface.I5')
     >>> iface
     [u'zope.app.component.interface.I5']
-    >>> tearDown()
-
+    >>> placelesssetup.tearDown()
     """
-
     return [iface_util[0]
             for iface_util in
             searchInterfaceUtilities(context, search_string, base)]
 
 
 def searchInterfaceUtilities(context, search_string=None, base=None):
-    utilityService = zapi.getGlobalService(zapi.servicenames.Utilities)   
-    iface_utilities = utilityService.getUtilitiesFor(IInterface)
+    gsm = zapi.getGlobalSiteManager()   
+    iface_utilities = gsm.getUtilitiesFor(IInterface)
 
     if search_string:
         search_string = search_string.lower()

Modified: Zope3/branches/srichter-blow-services/src/zope/app/component/metaconfigure.py
===================================================================
--- Zope3/branches/srichter-blow-services/src/zope/app/component/metaconfigure.py	2005-01-07 14:10:12 UTC (rev 28760)
+++ Zope3/branches/srichter-blow-services/src/zope/app/component/metaconfigure.py	2005-01-07 14:37:25 UTC (rev 28761)
@@ -18,7 +18,6 @@
 __docformat__ = 'restructuredtext'
 
 from zope.component.interfaces import IDefaultViewName, IFactory
-from zope.component.service import UndefinedService
 from zope.configuration.exceptions import ConfigurationError
 from zope.interface import Interface
 from zope.interface.interfaces import IInterface
@@ -34,28 +33,11 @@
 
 PublicPermission = 'zope.Public'
 
-# I prefer the indirection (using getService and getServices vs.
-# directly importing the various services)  not only because it makes
-# unit tests easier, but also because it reinforces that the services
-# should always be obtained through the
-# IPlacefulComponentArchitecture interface methods.
-
-# But these services aren't placeful! And we need to get at things that
-# normal service clients don't need!   Jim
-
-
-def handler(serviceName, methodName, *args, **kwargs):
-    method=getattr(zapi.getGlobalService(serviceName), methodName)
+def handler(methodName, *args, **kwargs):
+    method=getattr(zapi.getGlobalSiteManager(), methodName)
     method(*args, **kwargs)
 
-# We can't use the handler for serviceType, because serviceType needs
-# the interface service.
 from zope.app.component.interface import provideInterface
-
-def managerHandler(methodName, *args, **kwargs):
-    method=getattr(zapi.getGlobalServices(), methodName)
-    method(*args, **kwargs)
-
 def interface(_context, interface, type=None):
     _context.action(
         discriminator = None,
@@ -109,7 +91,7 @@
     _context.action(
         discriminator = None,
         callable = handler,
-        args = (zapi.servicenames.Adapters, 'subscribe',
+        args = ('subscribe',
                 for_, provides, factory),
         )
 
@@ -161,7 +143,7 @@
     _context.action(
         discriminator = ('adapter', for_, provides, name),
         callable = handler,
-        args = (zapi.servicenames.Adapters, 'register',
+        args = ('provideAdapter',
                 for_, provides, name, factory, _context.info),
         )
     _context.action(
@@ -195,7 +177,7 @@
     _context.action(
         discriminator = ('utility', provides, name),
         callable = handler,
-        args = ('Utilities', 'provideUtility',
+        args = ('provideUtility',
                 provides, component, name),
         )
     _context.action(
@@ -264,7 +246,7 @@
     _context.action(
         discriminator = ('resource', name, layer, provides),
         callable = handler,
-        args = (zapi.servicenames.Adapters, 'register',
+        args = ('provideAdapter',
                 (layer,), provides, name, factory, _context.info),
         )
     _context.action(
@@ -339,7 +321,7 @@
     _context.action(
         discriminator = ('view', for_, name, provides),
         callable = handler,
-        args = (zapi.servicenames.Adapters, 'register',
+        args = ('provideAdapter',
                 for_, provides, name, factory, _context.info),
         )
     if type is not None:
@@ -369,7 +351,7 @@
     _context.action(
         discriminator = ('defaultViewName', for_, type, name),
         callable = handler,
-        args = (zapi.servicenames.Adapters, 'register',
+        args = ('provideAdapter',
                 (for_, type), IDefaultViewName, '', name, _context.info)
         )
     
@@ -389,7 +371,7 @@
     _context.action(
         discriminator=('defaultLayer', type, layer),
         callable=handler,
-        args = (zapi.servicenames.Adapters, 'register',
+        args = ('provideAdapter',
                (type,), IInterface, 'defaultLayer',
                lambda request: layer, _context.info)
         )



More information about the Zope3-Checkins mailing list