[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services - adapter.py:1.1.2.2 configure.zcml:1.17.8.1 interfaces.py:1.1.2.2

Jim Fulton jim@zope.com
Wed, 11 Dec 2002 06:41:39 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services
In directory cvs.zope.org:/tmp/cvs-serv23318/lib/python/Zope/App/OFS/Services

Modified Files:
      Tag: AdapterAndView-branch
	adapter.py configure.zcml interfaces.py 
Log Message:
Got AdapterService views working.

=== Zope3/lib/python/Zope/App/OFS/Services/adapter.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/lib/python/Zope/App/OFS/Services/adapter.py:1.1.2.1	Tue Dec 10 09:38:36 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/adapter.py	Wed Dec 11 06:41:08 2002
@@ -23,10 +23,16 @@
 from Persistence.PersistentDict import PersistentDict
 from Zope.ComponentArchitecture.IAdapterService import IAdapterService
 from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
+from Zope.ComponentArchitecture import getServiceManager
 from Zope.App.OFS.Services.ConfigurationInterfaces import IConfigurable
 from Zope.App.OFS.Services.Configuration import ConfigurationRegistry
+from Zope.App.OFS.Services.Configuration import SimpleConfiguration
 from Zope.Proxy.ContextWrapper import ContextWrapper
 from Zope.ContextWrapper import ContextMethod
+from Zope.App.OFS.Services.Configuration import ConfigurationStatusProperty
+from Zope.App.ComponentArchitecture.NextService import getNextService
+
+from interfaces import IAdapterConfiguration
 
 class PersistentAdapterRegistry(Persistent, AdapterRegistry):
     
@@ -100,6 +106,33 @@
             adapter = registry.active().getAdapter(object)
             return adapter
 
-        return default
+        return getNextService(self, 'Adapters').queryAdapter(object,
+                                                             interface,
+                                                             default)
 
     queryAdapter = ContextMethod(queryAdapter)
+
+    def getRegisteredMatching(self,
+                              required_interfaces=None,
+                              provided_interfaces=None):
+        return self._registry.getRegisteredMatching(required_interfaces,
+                                                    provided_interfaces)
+
+class AdapterConfiguration(SimpleConfiguration):
+
+    __implements__ = IAdapterConfiguration
+
+    status = ConfigurationStatusProperty('Adapters')
+
+    def __init__(self, forInterface, providedInterface, factoryName):
+        self.forInterface = forInterface
+        self.providedInterface = providedInterface
+        self.factoryName = factoryName
+
+    def getAdapter(self, object):
+        sm = getServiceManager(self)
+        factory = sm.resolve(self.factoryName)        
+        return factory(object)
+
+    getAdapter = ContextMethod(getAdapter)
+    


=== Zope3/lib/python/Zope/App/OFS/Services/configure.zcml 1.17 => 1.17.8.1 ===
--- Zope3/lib/python/Zope/App/OFS/Services/configure.zcml:1.17	Wed Dec  4 16:46:17 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/configure.zcml	Wed Dec 11 06:41:08 2002
@@ -9,6 +9,30 @@
             />
 </content>
 
+<content class=".adapter.AdapterService">
+    <implements interface="Zope.App.OFS.Annotation.IAttributeAnnotatable." />
+    <factory id="Zope.App.OFS.Services.AdapterService"
+             permission="Zope.ManageServices"
+             />
+    <require permission="Zope.ManageServices"
+             interface=".ConfigurationInterfaces.IConfigurable"
+             attributes="getRegisteredMatching"
+             />
+</content>
+
+<content class=".adapter.AdapterConfiguration">
+    <require
+        permission="Zope.ManageServices"
+        interface=".interfaces.IAdapterConfiguration"
+        set_schema=
+            "Zope.App.OFS.Services.ConfigurationInterfaces.IConfiguration"
+        />
+    <require
+        permission="Zope.ManageServices"
+        interface="Zope.App.OFS.Container.IDeleteNotifiable."
+        />
+</content>    
+
 <include package=".ServiceManager" />
 <include package=".AuthenticationService" />
 <include package=".LocalEventService" />


=== Zope3/lib/python/Zope/App/OFS/Services/interfaces.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/lib/python/Zope/App/OFS/Services/interfaces.py:1.1.2.1	Tue Dec 10 09:38:36 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/interfaces.py	Wed Dec 11 06:41:08 2002
@@ -17,8 +17,33 @@
 """
 
 from ConfigurationInterfaces import IConfiguration
+from Zope.App.ComponentArchitecture.InterfaceField import InterfaceField
+from Zope.Schema import BytesLine
+from Interface import Interface
 
-class IAdapterConfiguration(IConfiguration):
+class IAdapterConfigurationInfo(Interface):
+
+    forInterface = InterfaceField(
+        title = u"For interface",
+        description = u"The interface of the objects being adapted",
+        readonly = True,
+        required = True,
+        )
+
+    providedInterface = InterfaceField(
+        title = u"Provided interface",
+        description = u"The interface provided by the adapter",
+        readonly = True,
+        required = True,
+        )
+
+    factoryName = BytesLine(
+        title=u"The dotted name of a factory for creating the adapter",
+        readonly = True,
+        required = True,
+        )
+
+class IAdapterConfiguration(IConfiguration, IAdapterConfigurationInfo):
 
     def getAdapter(object):
         """Return an adapter for the object