[Zope3-checkins] CVS: Zope3/src/zope/component - __init__.py:1.9.2.1 adapter.py:1.3.2.1 contextdependent.py:1.2.26.1 factory.py:1.2.26.1 interfaces.py:1.4.2.1 resource.py:1.2.26.1 service.py:1.3.26.1 skin.py:1.4.10.1 utility.py:1.3.14.1 view.py:1.2.26.1
Grégoire Weber
zope@i-con.ch
Sun, 22 Jun 2003 10:24:08 -0400
Update of /cvs-repository/Zope3/src/zope/component
In directory cvs.zope.org:/tmp/cvs-serv24874/src/zope/component
Modified Files:
Tag: cw-mail-branch
__init__.py adapter.py contextdependent.py factory.py
interfaces.py resource.py service.py skin.py utility.py
view.py
Log Message:
Synced up with HEAD
=== Zope3/src/zope/component/__init__.py 1.9 => 1.9.2.1 ===
--- Zope3/src/zope/component/__init__.py:1.9 Wed May 21 16:30:05 2003
+++ Zope3/src/zope/component/__init__.py Sun Jun 22 10:23:37 2003
@@ -33,12 +33,7 @@
return ob
moduleProvides(IComponentArchitecture)
-
-def queryServiceManager(context, default=None):
- try:
- return getServiceManager(context)
- except ComponentLookupError:
- return default
+__all__ = tuple(IComponentArchitecture)
def getServiceManager(context):
return serviceManager
@@ -48,9 +43,7 @@
return getServiceManager(context).getService(name)
def queryService(context, name, default=None):
- sm = queryServiceManager(context)
- if sm is None:
- return default
+ sm = getServiceManager(context)
return sm.queryService(name, default)
def getServiceDefinitions(context):
@@ -68,7 +61,7 @@
# Adapter service
def getAdapter(object, interface, name='', context=None):
- adapter = queryAdapter(object, interface, name=name, context=context)
+ adapter = queryAdapter(object, interface, None, name, context)
if adapter is None:
raise ComponentLookupError(object, interface)
return adapter
@@ -103,15 +96,8 @@
if interface.isImplementedBy(object):
return object
- if context is None:
- context = object
- try:
- adapters = getService(context, Adapters)
- except ComponentLookupError:
- # Oh blast, no adapter service. We're probably just running from a test
- return default
+ return queryNamedAdapter(object, interface, name, default, context)
- return adapters.queryNamedAdapter(object, interface, name, default)
def getNamedAdapter(object, interface, name, context=None):
adapter = queryNamedAdapter(object, interface, name, context=context)
@@ -130,6 +116,8 @@
return adapters.queryNamedAdapter(object, interface, name, default)
+queryNamedAdapter = hookable(queryNamedAdapter)
+
# Factory service
def createObject(context, name, *args, **kwargs):
@@ -190,4 +178,3 @@
return getService(wrapped_object,
Resources).queryResource(
wrapped_object, name, request, default)
-
=== Zope3/src/zope/component/adapter.py 1.3 => 1.3.2.1 ===
--- Zope3/src/zope/component/adapter.py:1.3 Wed May 21 16:30:05 2003
+++ Zope3/src/zope/component/adapter.py Sun Jun 22 10:23:37 2003
@@ -14,6 +14,7 @@
"""adapter service
"""
+__metaclass__ = type
import sys
from zope.interface import implements
from zope.interface.adapter import AdapterRegistry
@@ -21,7 +22,7 @@
from zope.component.interfaces import IGlobalAdapterService
import warnings
-class GlobalAdapterService(object):
+class GlobalAdapterService:
implements(IGlobalAdapterService)
@@ -70,7 +71,7 @@
warnings.warn("The name argument to queryAdapter is deprecated",
DeprecationWarning, 2)
return self.queryNamedAdapter(object, interface, name, default)
-
+
conform = getattr(object, '__conform__', None)
if conform is not None:
try:
=== Zope3/src/zope/component/contextdependent.py 1.2 => 1.2.26.1 ===
--- Zope3/src/zope/component/contextdependent.py:1.2 Wed Dec 25 09:13:31 2002
+++ Zope3/src/zope/component/contextdependent.py Sun Jun 22 10:23:37 2003
@@ -17,11 +17,12 @@
"""
from zope.component.interfaces import IContextDependent
+from zope.interface import implements
class ContextDependent(object):
"""standard boilerplate for context dependent objects"""
- __implements__ = IContextDependent
+ implements(IContextDependent)
def __init__(self, context):
self.context = context
=== Zope3/src/zope/component/factory.py 1.2 => 1.2.26.1 ===
--- Zope3/src/zope/component/factory.py:1.2 Wed Dec 25 09:13:31 2002
+++ Zope3/src/zope/component/factory.py Sun Jun 22 10:23:37 2003
@@ -16,6 +16,7 @@
from zope.interface.verify import verifyObject
+from zope.interface import implements
from zope.component.interfaces import IFactory
from zope.component.interfaces import IFactoryService
from zope.component.exceptions import ComponentLookupError
@@ -28,7 +29,7 @@
class GlobalFactoryService:
- __implements__ = IGlobalFactoryService
+ implements(IGlobalFactoryService)
def __init__(self):
self.__factories={}
=== Zope3/src/zope/component/interfaces.py 1.4 => 1.4.2.1 ===
--- Zope3/src/zope/component/interfaces.py:1.4 Wed May 21 16:30:05 2003
+++ Zope3/src/zope/component/interfaces.py Sun Jun 22 10:23:37 2003
@@ -26,16 +26,23 @@
# basic service manager tools
def getServiceManager(context):
- """returns the nearest service manager to the context; if the
- context is None the global service manager is always returned"""
+ """Get the service manager
+
+ Return the nearest service manager to the context; if the
+ context is None the global service manager is always returned
+ """
def getService(context, name):
- """returns the service defined by 'name' nearest to the context;
+ """Get a named service.
+
+ Returns the service defined by 'name' nearest to the context;
if the context is None the pertinent global service is always
returned"""
def getServiceDefinitions(context):
- """returns a dictionary of the service definitions pertinent to
+ """Get service definitions
+
+ Returns a dictionary of the service definitions pertinent to
the given context, in the format {nameString: serviceInterface}.
If the context is None the global definitions will be returned.
The default behavior of placeful service managers is to include
@@ -125,7 +132,7 @@
def createObject(context, name, *args, **kwargs):
"""Create an object using a factory
- finds the factory of the given name that is nearest to the
+ Finds the factory of the given name that is nearest to the
context, and passes the other given arguments to the factory
to create a new instance. Returns a reference to the new
object. If a matching factory cannot be found raises
@@ -133,8 +140,28 @@
"""
+ def getFactory(context, name):
+ """Get a factory
+
+ Get the factory of the given name that is nearest to the
+ context. If a matching factory cannot be found raises
+ ComponentLookupError
+
+ """
+
+ def queryFactory(context, name, default=None):
+ """Get a factory
+
+ Get the factory of the given name that is nearest to the
+ context. If a matching factory cannot be found then the
+ default is returned.
+
+ """
+
def getFactoryInterfaces(context, name):
- """finds the factory of the given name that is nearest to the
+ """Get interfaces implemented by a factory
+
+ finds the factory of the given name that is nearest to the
context, and returns the interface or interface tuple that
object instances created by the named factory will implement."""
=== Zope3/src/zope/component/resource.py 1.2 => 1.2.26.1 ===
--- Zope3/src/zope/component/resource.py:1.2 Wed Dec 25 09:13:31 2002
+++ Zope3/src/zope/component/resource.py Sun Jun 22 10:23:37 2003
@@ -17,6 +17,7 @@
"""
from zope.interface.implementor import ImplementorRegistry
+from zope.interface import implements
from zope.component.exceptions import ComponentLookupError
from zope.component import getSkin
from zope.component.interfaces import IResourceService
@@ -47,7 +48,7 @@
def __init__(self):
self.__layers = {}
- __implements__ = IGlobalResourceService
+ implements(IGlobalResourceService)
def getResource(self, object, name, request):
'''See interface IResourceService'''
=== Zope3/src/zope/component/service.py 1.3 => 1.3.26.1 ===
--- Zope3/src/zope/component/service.py:1.3 Fri Dec 27 20:42:21 2002
+++ Zope3/src/zope/component/service.py Sun Jun 22 10:23:37 2003
@@ -19,6 +19,7 @@
from zope.exceptions import DuplicationError
from zope.component.interfaces import IServiceService
from zope.component.exceptions import ComponentLookupError
+from zope.interface import implements
class IGlobalServiceManager(IServiceService):
@@ -52,7 +53,7 @@
class GlobalServiceManager:
"""service manager"""
- __implements__ = IGlobalServiceManager
+ implements(IGlobalServiceManager)
def __init__(self):
self.__defs = {}
=== Zope3/src/zope/component/skin.py 1.4 => 1.4.10.1 ===
--- Zope3/src/zope/component/skin.py:1.4 Thu May 1 15:35:38 2003
+++ Zope3/src/zope/component/skin.py Sun Jun 22 10:23:37 2003
@@ -17,6 +17,7 @@
"""
from zope.interface.implementor import ImplementorRegistry
+from zope.interface import implements
from zope.component.interfaces import ISkinService
class IGlobalSkinService(ISkinService):
@@ -34,7 +35,7 @@
def __init__(self):
self.__skins = {}
- __implements__ = IGlobalSkinService
+ implements(IGlobalSkinService)
def defineSkin(self, name, view_type, layers):
'''See interface IGlobalSkinService'''
=== Zope3/src/zope/component/utility.py 1.3 => 1.3.14.1 ===
--- Zope3/src/zope/component/utility.py:1.3 Fri Apr 11 09:38:28 2003
+++ Zope3/src/zope/component/utility.py Sun Jun 22 10:23:37 2003
@@ -17,6 +17,7 @@
"""
from zope.interface.implementor import ImplementorRegistry
+from zope.interface import implements
from zope.component.interfaces import IUtilityService
from zope.component.exceptions import Invalid, ComponentLookupError
@@ -30,7 +31,7 @@
class GlobalUtilityService:
- __implements__=IGlobalUtilityService
+ implements(IGlobalUtilityService)
def __init__(self):
self.__utilities = {}
=== Zope3/src/zope/component/view.py 1.2 => 1.2.26.1 ===
--- Zope3/src/zope/component/view.py:1.2 Wed Dec 25 09:13:31 2002
+++ Zope3/src/zope/component/view.py Sun Jun 22 10:23:37 2003
@@ -17,6 +17,7 @@
"""
from zope.interface.adapter import AdapterRegistry
+from zope.interface import implements
from zope.component.exceptions import ComponentLookupError
from zope.component import getSkin
from zope.component.interfaces import IViewService
@@ -39,7 +40,7 @@
class GlobalViewService:
- __implements__ = IGlobalViewService
+ implements(IGlobalViewService)
def __init__(self):
self.__layers = {}