[Zope3-checkins] CVS: Zope3/src/zope/app/services - registration.py:1.1 adapter.py:1.19 cache.py:1.15 configure.zcml:1.38 connection.py:1.15 factories.py:1.3 folder.py:1.11 pagefolder.py:1.11 service.py:1.26 utility.py:1.11 utility.zcml:1.4 view.py:1.24 configuration.py:NONE
Jim Fulton
jim@zope.com
Sat, 21 Jun 2003 17:22:44 -0400
Update of /cvs-repository/Zope3/src/zope/app/services
In directory cvs.zope.org:/tmp/cvs-serv2745/src/zope/app/services
Modified Files:
adapter.py cache.py configure.zcml connection.py factories.py
folder.py pagefolder.py service.py utility.py utility.zcml
view.py
Added Files:
registration.py
Removed Files:
configuration.py
Log Message:
Major refactoring to reflect change in terminology from
"configuration" to "registration" to refer to the configuration of how
objects are used (as opposed to their internal configuration).
=== Added File Zope3/src/zope/app/services/registration.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Component registration support for services
$Id: registration.py,v 1.1 2003/06/21 21:22:12 jim Exp $
"""
__metaclass__ = type
from persistence import Persistent
from zope.interface import implements
from zope.app.interfaces.annotation import IAnnotations
from zope.app.interfaces.annotation import IAttributeAnnotatable
from zope.app.interfaces.container import IAddNotifiable, IDeleteNotifiable
from zope.app.interfaces.container import IZopeWriteContainer
from zope.app.interfaces.dependable import IDependable, DependencyError
from zope.app.interfaces.services.registration import IRegistrationManager
from zope.app.interfaces.services.registration import IRegistrationStack
from zope.app.interfaces.services.registration \
import INameComponentRegistry
from zope.app.interfaces.services.registration import INamedRegistration
from zope.app.interfaces.services.registration import IRegistration
from zope.app.interfaces.services.registration \
import INamedComponentRegistration
from zope.app.interfaces.services.registration import INameRegistry
from zope.app.interfaces.services.registration \
import INamedComponentRegistration, IComponentRegistration
from zope.app.interfaces.services.registration import IRegistered
from zope.app.interfaces.services.registration \
import NoRegistrationManagerError
from zope.app.interfaces.services.registration import NoLocalServiceError
from zope.app.interfaces.services.registration import UnregisteredStatus
from zope.app.interfaces.services.registration import ActiveStatus
from zope.app.interfaces.services.registration import RegisteredStatus
from zope.app.traversing import getRoot, getPath, traverse
from zope.component import getAdapter, queryAdapter
from zope.component import getServiceManager
from zope.app.context import ContextWrapper
from zope.context import ContextMethod, ContextDescriptor, getWrapperContainer
from zope.proxy import removeAllProxies
from zope.security.checker import InterfaceChecker
from zope.security.proxy import Proxy, trustedRemoveSecurityProxy
from zope.proxy import getProxiedObject
class RegistrationStatusProperty(ContextDescriptor):
def __get__(self, inst, klass):
if inst is None:
return self
registration = inst
sm = getServiceManager(registration)
service = sm.queryLocalService(registration.serviceType)
# XXX The following may fail; there's a subtle bug here when
# the returned service isn't in the same service manager as
# the one owning the registration.
registry = service and service.queryRegistrationsFor(registration)
if registry:
if registry.active() == registration:
return ActiveStatus
if registry.registered(registration):
return RegisteredStatus
return UnregisteredStatus
def __set__(self, inst, value):
registration = inst
sm = getServiceManager(registration)
service = sm.queryLocalService(registration.serviceType)
registry = service and service.queryRegistrationsFor(registration)
if value == UnregisteredStatus:
if registry:
registry.unregister(registration)
else:
if not service:
raise NoLocalServiceError(
"This registration change cannot be performed because "
"there isn't a corresponding %s service defined in this "
"site. To proceed, first add a local %s service."
% (registration.serviceType, registration.serviceType))
if registry is None:
registry = service.createRegistrationsFor(registration)
if value == RegisteredStatus:
if registry.active() == registration:
registry.deactivate(registration)
else:
registry.register(registration)
elif value == ActiveStatus:
if not registry.registered(registration):
registry.register(registration)
registry.activate(registration)
class RegistrationStack(Persistent):
"""Registration registry implementation.
The invariants for _data are as follows:
(1) The last element (if any) is not None
(2) No value occurs more than once
(3) Each value except None is a relative path from the nearest
service manager to an object implementing IRegistration
"""
implements(IRegistrationStack)
_data = ()
def _id(self, ob):
# Get and check relative path
path = getPath(ob)
prefix = "/++etc++site/"
lpackages = path.rfind(prefix)
if lpackages < 0:
# XXX Backward compatability
prefix = "/++etc++Services/"
lpackages = path.rfind(prefix)
if lpackages < 0:
raise ValueError("Registration object is in an invalid location",
path)
rpath = path[lpackages+len(prefix):]
if not rpath or (".." in rpath.split("/")):
raise ValueError("Registration object is in an invalid location",
path)
return rpath
def register(wrapped_self, registration):
cid = wrapped_self._id(registration)
if wrapped_self._data:
if cid in wrapped_self._data:
return # already registered
else:
# Nothing registered. Need to stick None in front so that nothing
# is active.
wrapped_self._data = (None, )
wrapped_self._data += (cid, )
register = ContextMethod(register)
def unregister(wrapped_self, registration):
cid = wrapped_self._id(registration)
data = wrapped_self._data
if data:
if data[0] == cid:
# Tell it that it is no longer active
registration.deactivated()
# Remove it from our data
data = tuple([item for item in data if item != cid])
# Check for trailing None
if data and data[-1] is None:
data = data[:-1]
if data and data[0] is not None:
# Activate the newly active component
sm = getServiceManager(wrapped_self)
new = traverse(sm, data[0])
new.activated()
# Write data back
wrapped_self._data = data
unregister = ContextMethod(unregister)
def registered(wrapped_self, registration):
cid = wrapped_self._id(registration)
return cid in wrapped_self._data
registered = ContextMethod(registered)
def activate(wrapped_self, registration):
if registration is None:
cid = None
else:
cid = wrapped_self._id(registration)
data = wrapped_self._data
if cid is None and not data:
return # already in the state we want
if cid is None or cid in data:
if data[0] == cid:
return # already active
if data[0] is not None:
# Deactivate the currently active component
sm = getServiceManager(wrapped_self)
old = traverse(sm, data[0])
old.deactivated()
# Insert it in front, removing it from back
data = (cid, ) + tuple([item for item in data if item != cid])
# Check for trailing None
if data[-1] == None:
data = data[:-1]
# Write data back
wrapped_self._data = data
if registration is not None:
# Tell it that it is now active
registration.activated()
else:
raise ValueError(
"Registration to be activated is not registered",
registration)
activate = ContextMethod(activate)
def deactivate(wrapped_self, registration):
cid = wrapped_self._id(registration)
data = wrapped_self._data
if cid not in data:
raise ValueError(
"Registration to be deactivated is not registered",
registration)
if data[0] != cid:
return # already inactive
# Tell it that it is no longer active
registration.deactivated()
if None not in data:
# Append None
data += (None,)
# Move it to the end
data = data[1:] + data[:1]
if data[0] is not None:
# Activate the newly active component
sm = getServiceManager(wrapped_self)
new = traverse(sm, data[0])
new.activated()
# Write data back
wrapped_self._data = data
deactivate = ContextMethod(deactivate)
def active(wrapped_self):
if wrapped_self._data:
path = wrapped_self._data[0]
if path is not None:
# Make sure we can traverse to it.
sm = getServiceManager(wrapped_self)
registration = traverse(sm, path)
return registration
return None
active = ContextMethod(active)
def __nonzero__(self):
return bool(self._data)
def info(wrapped_self, keep_dummy=False):
sm = getServiceManager(wrapped_self)
data = wrapped_self._data
if not data and keep_dummy:
data += (None,)
result = [{'id': path or "",
'active': False,
'registration': (path and traverse(sm, path))
}
for path in data if path or keep_dummy
]
if keep_dummy or (result and result[0]['registration'] is not None):
result[0]['active'] = True
return result
info = ContextMethod(info)
class SimpleRegistration(Persistent):
"""Registration objects that just contain registration data
Classes that derive from this must make sure they implement
IDeleteNotifiable either by implementing
implementedBy(SimpleRegistration) or explicitly implementing
IDeleteNotifiable.
"""
implements(IRegistration, IDeleteNotifiable,
# We are including this here because we want all of the
# subclasses to get it and we don't really need to be
# flexible about the policy here. At least we don't
# *think* we do. :)
IAttributeAnnotatable,
)
# Methods from IRegistration
def activated(self):
pass
def deactivated(self):
pass
def usageSummary(self):
return self.__class__.__name__
def implementationSummary(self):
return ""
# Methods from IDeleteNotifiable
def beforeDeleteHook(self, registration, container):
"See IDeleteNotifiable"
objectstatus = registration.status
if objectstatus == ActiveStatus:
try:
objectpath = getPath(registration)
except: # XXX
objectpath = str(registration)
raise DependencyError("Can't delete active registration (%s)"
% objectpath)
elif objectstatus == RegisteredStatus:
registration.status = UnregisteredStatus
class NamedRegistration(SimpleRegistration):
"""Named registration
"""
implements(INamedRegistration)
def __init__(self, name):
self.name = name
def usageSummary(self):
return "%s %s" % (self.name, self.__class__.__name__)
class ComponentRegistration(SimpleRegistration):
"""Component registration.
Subclasses should define a getInterface() method returning the interface
of the component.
"""
# SimpleRegistration implements IDeleteNotifiable, so we don't need
# it below.
implements(IComponentRegistration, IAddNotifiable)
def __init__(self, component_path, permission=None):
self.componentPath = component_path
if permission == 'zope.Public':
permission = CheckerPublic
self.permission = permission
def implementationSummary(self):
return self.componentPath
def getComponent(wrapped_self):
service_manager = getServiceManager(wrapped_self)
# The user of the registration object may not have permission
# to traverse to the component. Yet they should be able to
# get it by calling getComponent() on a registration object
# for which they do have permission. What they get will be
# wrapped in a security proxy of course. Hence:
# We have to be clever here. We need to do an honest to
# god unrestricted traveral, which means we have to
# traverse from an unproxied object. But, it's not enough
# for the service manager to be unproxied, because the
# path is an absolute path. When absolute paths are
# traversed, the traverser finds the physical root and
# traverses from there, so we need to make sure the
# physical root isn't proxied.
path = wrapped_self.componentPath
# Get the root and unproxy it
root = removeAllProxies(getRoot(service_manager))
if path.startswith("/"):
# Absolute path
component = traverse(root, path)
else:
# Relative path.
# XXX We do a strange little dance because we want the
# context to inherit the unproxied root, and this is
# the only way to keep it.
ancestor = getWrapperContainer(getWrapperContainer(wrapped_self))
ancestor = traverse(root, getPath(ancestor))
component = traverse(ancestor, path)
if wrapped_self.permission:
if type(component) is Proxy:
# There should be at most one security Proxy around an object.
# So, if we're going to add a new security proxy, we need to
# remove any existing one.
component = trustedRemoveSecurityProxy(component)
interface = wrapped_self.getInterface()
checker = InterfaceChecker(interface, wrapped_self.permission)
component = Proxy(component, checker)
return component
getComponent = ContextMethod(getComponent)
def afterAddHook(self, registration, container):
"See IAddNotifiable"
component = registration.getComponent()
dependents = getAdapter(component, IDependable)
objectpath = getPath(registration)
dependents.addDependent(objectpath)
# Also update usage, if supported
adapter = queryAdapter(component, IRegistered)
if adapter is not None:
adapter.addUsage(getPath(registration))
def beforeDeleteHook(self, registration, container):
"See IDeleteNotifiable"
super(ComponentRegistration, self).beforeDeleteHook(registration,
container)
component = registration.getComponent()
dependents = getAdapter(component, IDependable)
objectpath = getPath(registration)
dependents.removeDependent(objectpath)
# Also update usage, if supported
adapter = queryAdapter(component, IRegistered)
if adapter is not None:
adapter.removeUsage(getPath(registration))
class NamedComponentRegistration(NamedRegistration, ComponentRegistration):
"""Registrations for named components.
This configures components that live in folders, by name.
"""
implements(INamedComponentRegistration)
def __init__(self, name, component_path, permission=None):
NamedRegistration.__init__(self, name)
ComponentRegistration.__init__(self, component_path, permission)
class NameRegistry:
"""Mixin for implementing INameRegistry
"""
implements(INameRegistry)
def __init__(self, *args, **kw):
self._bindings = {}
super(NameRegistry, self).__init__(*args, **kw)
def queryRegistrationsFor(wrapped_self, cfg, default=None):
"""See IRegistry"""
return wrapped_self.queryRegistrations(cfg.name, default)
queryRegistrationsFor = ContextMethod(queryRegistrationsFor)
def queryRegistrations(wrapped_self, name, default=None):
"""See INameRegistry"""
registry = wrapped_self._bindings.get(name, default)
return ContextWrapper(registry, wrapped_self)
queryRegistrations = ContextMethod(queryRegistrations)
def createRegistrationsFor(wrapped_self, cfg):
"""See IRegistry"""
return wrapped_self.createRegistrations(cfg.name)
createRegistrationsFor = ContextMethod(createRegistrationsFor)
def createRegistrations(wrapped_self, name):
"""See INameRegistry"""
try:
registry = wrapped_self._bindings[name]
except KeyError:
wrapped_self._bindings[name] = registry = RegistrationStack()
wrapped_self._p_changed = 1
return ContextWrapper(registry, wrapped_self)
createRegistrations = ContextMethod(createRegistrations)
def listRegistrationNames(wrapped_self):
"""See INameRegistry"""
return filter(wrapped_self._bindings.get,
wrapped_self._bindings.keys())
class NameComponentRegistry(NameRegistry):
"""Mixin for implementing INameComponentRegistry
"""
implements(INameComponentRegistry)
def queryActiveComponent(wrapped_self, name, default=None):
"""See INameComponentRegistry"""
registry = wrapped_self.queryRegistrations(name)
if registry:
registration = registry.active()
if registration is not None:
return registration.getComponent()
return default
queryActiveComponent = ContextMethod(queryActiveComponent)
from zope.app.dependable import PathSetAnnotation
class Registered(PathSetAnnotation):
"""An adapter from IRegisterable to IRegistered.
This class is the only place that knows how 'Registered'
data is represented.
"""
implements(IRegistered)
# We want to use this key:
# key = "zope.app.services.registration.Registered"
# But we have existing annotations with the following key, so we'll keep
# it. :(
key = "zope.app.services.configuration.UseConfiguration"
addUsage = PathSetAnnotation.addPath
removeUsage = PathSetAnnotation.removePath
usages = PathSetAnnotation.getPaths
class RegistrationManager(Persistent):
"""Registration manager
Manages registrations within a package.
"""
implements(IRegistrationManager, IDeleteNotifiable)
def __init__(self):
self._data = ()
self._next = 0
def __getitem__(self, key):
"See IItemContainer"
v = self.get(key)
if v is None:
raise KeyError, key
return v
def get(self, key, default=None):
"See IReadMapping"
for k, v in self._data:
if k == key:
return v
return default
def __contains__(self, key):
"See IReadMapping"
return self.get(key) is not None
def keys(self):
"See IEnumerableMapping"
return [k for k, v in self._data]
def __iter__(self):
return iter(self.keys())
def values(self):
"See IEnumerableMapping"
return [v for k, v in self._data]
def items(self):
"See IEnumerableMapping"
return self._data
def __len__(self):
"See IEnumerableMapping"
return len(self._data)
def setObject(self, key, object):
"See IWriteContainer"
self._next += 1
if key:
if key in self:
raise DuplicationError("key is already registered", key)
try:
n = int(key)
except ValueError:
pass
else:
if n > self._next:
self._next = n
else:
key = str(self._next)
while key in self:
self._next += 1
key = str(self._next)
self._data += ((key, object), )
return key
def __delitem__(self, key):
"See IWriteContainer"
if key not in self:
raise KeyError, key
self._data = tuple(
[item
for item in self._data
if item[0] != key]
)
def moveTop(self, names):
self._data = tuple(
[item for item in self._data if (item[0] in names)]
+
[item for item in self._data if (item[0] not in names)]
)
def moveBottom(self, names):
self._data = tuple(
[item for item in self._data if (item[0] not in names)]
+
[item for item in self._data if (item[0] in names)]
)
def _moveUpOrDown(self, names, direction):
# Move each named item by one position. Note that this
# might require moving some unnamed objects by more than
# one position.
indexes = {}
# Copy named items to positions one less than they currently have
i = -1
for item in self._data:
i += 1
if item[0] in names:
j = max(i + direction, 0)
while j in indexes:
j += 1
indexes[j] = item
# Fill in the rest where there's room.
i = 0
for item in self._data:
if item[0] not in names:
while i in indexes:
i += 1
indexes[i] = item
items = indexes.items()
items.sort()
self._data = tuple([item[1] for item in items])
def moveUp(self, names):
self._moveUpOrDown(names, -1)
def moveDown(self, names):
self._moveUpOrDown(names, 1)
def beforeDeleteHook(self, object, container):
assert object == self
container = getAdapter(object, IZopeWriteContainer)
for k, v in self._data:
del container[k]
class RegistrationManagerContainer(object):
"""Mix-in to implement IRegistrationManagerContainer
"""
def __init__(self):
super(RegistrationManagerContainer, self).__init__()
self.setObject('RegistrationManager', RegistrationManager())
def __delitem__(self, name):
"""Delete an item, but not if it's the last registration manager
"""
item = self[name]
if IRegistrationManager.isImplementedBy(item):
# Check to make sure it's not the last one
if len([i for i in self.values()
if IRegistrationManager.isImplementedBy(i)]) < 2:
raise NoRegistrationManagerError(
"Can't delete the last registration manager")
super(RegistrationManagerContainer, self).__delitem__(name)
def getRegistrationManager(self):
"""Get a registration manager
"""
# Get the registration manager for this folder
for name in self:
item = self[name]
if IRegistrationManager.isImplementedBy(item):
# We found one. Get it in context
return ContextWrapper(item, self, name=name)
else:
raise NoRegistrationManagerError(
"Couldn't find an registration manager")
getRegistrationManager = ContextMethod(getRegistrationManager)
from zope.xmlpickle import dumps, loads
from zope.app.interfaces.fssync import IObjectFile
from zope.app.fssync.classes import ObjectEntryAdapter
class ComponentRegistrationAdapter(ObjectEntryAdapter):
"""Fssync adapter for ComponentRegistration objects and subclasses.
This is fairly generic -- it should apply to most subclasses of
ComponentRegistration. But in order for it to work for a
specific subclass (say, UtilityRegistration), you have to (a) add
an entry to configure.zcml, like this:
<fssync:adapter
class=".utility.UtilityRegistration"
factory=".registration.ComponentRegistrationAdapter"
/>
and (b) add a function to factories.py, like this:
def UtilityRegistration():
from zope.app.services.utility import UtilityRegistration
return UtilityRegistration("", None, "")
The file representation of a registration object is an XML pickle
for a modified version of the instance dict. In this version of
the instance dict, the __annotations__ attribute is omitted,
because annotations are already stored on the filesystem in a
different way (in @@Zope/Annotations/<file>).
"""
implements(IObjectFile)
def factory(self):
"""See IObjectEntry."""
name = self.context.__class__.__name__
return "zope.app.services.factories." + name
def getBody(self):
"""See IObjectEntry."""
obj = removeAllProxies(self.context)
ivars = {}
ivars.update(obj.__getstate__())
aname = "__annotations__"
if aname in ivars:
del ivars[aname]
return dumps(ivars)
def setBody(self, body):
"""See IObjectEntry."""
obj = removeAllProxies(self.context)
ivars = loads(body)
obj.__setstate__(ivars)
# XXX Pickle backward compatability
ConfigurationRegistry = RegistrationStack
ConfigurationManager = RegistrationManager
import sys
sys.modules['zope.app.services.registrationmanager'
] = sys.modules['zope.app.services.registration']
sys.modules['zope.app.services.configuration'
] = sys.modules['zope.app.services.registration']
=== Zope3/src/zope/app/services/adapter.py 1.18 => 1.19 ===
--- Zope3/src/zope/app/services/adapter.py:1.18 Thu Jun 19 17:55:45 2003
+++ Zope3/src/zope/app/services/adapter.py Sat Jun 21 17:22:12 2003
@@ -26,16 +26,16 @@
from zope.component.exceptions import ComponentLookupError
from zope.component import getServiceManager
from zope.app.services.servicenames import Adapters
-from zope.app.interfaces.services.configuration import IConfigurable
-from zope.app.services.configuration import ConfigurationRegistry
-from zope.app.services.configuration import SimpleConfiguration
+from zope.app.interfaces.services.registration import IRegistry
+from zope.app.services.registration import RegistrationStack
+from zope.app.services.registration import SimpleRegistration
from zope.app.context import ContextWrapper
from zope.context import ContextMethod
-from zope.app.services.configuration import ConfigurationStatusProperty
+from zope.app.services.registration import RegistrationStatusProperty
from zope.app.component.nextservice import getNextService
from zope.app.interfaces.services.service import ISimpleService
-from zope.app.interfaces.services.adapter import IAdapterConfiguration
+from zope.app.interfaces.services.adapter import IAdapterRegistration
class PersistentAdapterRegistry(Persistent, AdapterRegistry):
@@ -45,22 +45,22 @@
class AdapterService(Persistent):
- implements(IAdapterService, IConfigurable, ISimpleService)
+ implements(IAdapterService, IRegistry, ISimpleService)
def __init__(self):
self._byName = PersistentDict()
- def queryConfigurationsFor(self, configuration, default=None):
- "See IConfigurable"
+ def queryRegistrationsFor(self, registration, default=None):
+ "See IRegistry"
# XXX Need to add named adapter support
- return self.queryConfigurations(
- configuration.forInterface, configuration.providedInterface,
- configuration.adapterName,
+ return self.queryRegistrations(
+ registration.forInterface, registration.providedInterface,
+ registration.adapterName,
default)
- queryConfigurationsFor = ContextMethod(queryConfigurationsFor)
+ queryRegistrationsFor = ContextMethod(queryRegistrationsFor)
- def queryConfigurations(self,
+ def queryRegistrations(self,
forInterface, providedInterface, adapterName,
default=None):
@@ -74,18 +74,18 @@
return ContextWrapper(registry, self)
- queryConfigurations = ContextMethod(queryConfigurations)
+ queryRegistrations = ContextMethod(queryRegistrations)
- def createConfigurationsFor(self, configuration):
- "See IConfigurable"
+ def createRegistrationsFor(self, registration):
+ "See IRegistry"
# XXX Need to add named adapter support
- return self.createConfigurations(
- configuration.forInterface, configuration.providedInterface,
- configuration.adapterName)
+ return self.createRegistrations(
+ registration.forInterface, registration.providedInterface,
+ registration.adapterName)
- createConfigurationsFor = ContextMethod(createConfigurationsFor)
+ createRegistrationsFor = ContextMethod(createRegistrationsFor)
- def createConfigurations(self, forInterface, providedInterface, name):
+ def createRegistrations(self, forInterface, providedInterface, name):
adapters = self._byName.get(name)
if adapters is None:
@@ -94,12 +94,12 @@
registry = adapters.getRegistered(forInterface, providedInterface)
if registry is None:
- registry = ConfigurationRegistry()
+ registry = RegistrationStack()
adapters.register(forInterface, providedInterface, registry)
return ContextWrapper(registry, self)
- createConfigurations = ContextMethod(createConfigurations)
+ createRegistrations = ContextMethod(createRegistrations)
def getAdapter(self, object, interface, name=''):
"See IAdapterService"
@@ -187,13 +187,13 @@
return adapters.getRegisteredMatching(for_interfaces,
provided_interfaces)
-class AdapterConfiguration(SimpleConfiguration):
+class AdapterRegistration(SimpleRegistration):
- implements(IAdapterConfiguration)
+ implements(IAdapterRegistration)
serviceType = Adapters
- status = ConfigurationStatusProperty()
+ status = RegistrationStatusProperty()
# XXX These should be positional arguments, except that forInterface
# isn't passed in if it is omitted. To fix this, we need a
@@ -219,3 +219,6 @@
return factory(object)
getAdapter = ContextMethod(getAdapter)
+
+# XXX Pickle backward compatability
+AdapterConfiguration = AdapterRegistration
=== Zope3/src/zope/app/services/cache.py 1.14 => 1.15 ===
--- Zope3/src/zope/app/services/cache.py:1.14 Thu Jun 19 17:55:45 2003
+++ Zope3/src/zope/app/services/cache.py Sat Jun 21 17:22:12 2003
@@ -17,30 +17,27 @@
"""
from persistence import Persistent
-
-from zope.component import getService
-from zope.context import ContextMethod
-
from zope.app.component.nextservice import queryNextService
from zope.app.interfaces.cache.cache import ICache, ICachingService
from zope.app.interfaces.event import IObjectModifiedEvent
-from zope.app.interfaces.services.cache import ICacheConfiguration
-from zope.app.interfaces.services.configuration \
- import INameComponentConfigurable
+from zope.app.interfaces.services.cache import ICacheRegistration
+from zope.app.interfaces.services.registration import INameComponentRegistry
from zope.app.interfaces.services.event import IEventChannel
from zope.app.interfaces.services.service import ISimpleService
-from zope.app.services.configuration import ConfigurationStatusProperty
-from zope.app.services.configuration import NameComponentConfigurable
-from zope.app.services.configuration import NamedComponentConfiguration
+from zope.app.services.registration import RegistrationStatusProperty
+from zope.app.services.registration import NameComponentRegistry
+from zope.app.services.registration import NamedComponentRegistration
from zope.app.services.event import ServiceSubscriberEventChannel
+from zope.component import getService
+from zope.context import ContextMethod
from zope.interface import implements
class ILocalCachingService(ICachingService, IEventChannel,
- INameComponentConfigurable):
+ INameComponentRegistry):
"""TTW manageable caching service"""
-class CachingService(ServiceSubscriberEventChannel, NameComponentConfigurable):
+class CachingService(ServiceSubscriberEventChannel, NameComponentRegistry):
implements(ILocalCachingService, ISimpleService)
@@ -57,7 +54,7 @@
# --Guido
Persistent.__init__(self)
ServiceSubscriberEventChannel.__init__(self)
- NameComponentConfigurable.__init__(self)
+ NameComponentRegistry.__init__(self)
def getCache(wrapped_self, name):
'See ICachingService'
@@ -81,8 +78,8 @@
def getAvailableCaches(wrapped_self):
'See ICachingService'
caches = {}
- for name in wrapped_self.listConfigurationNames():
- registry = wrapped_self.queryConfigurations(name)
+ for name in wrapped_self.listRegistrationNames():
+ registry = wrapped_self.queryRegistrations(name)
if registry.active() is not None:
caches[name] = 0
service = queryNextService(wrapped_self, "Caching")
@@ -93,15 +90,15 @@
getAvailableCaches = ContextMethod(getAvailableCaches)
-class CacheConfiguration(NamedComponentConfiguration):
+class CacheRegistration(NamedComponentRegistration):
- __doc__ = ICacheConfiguration.__doc__
+ __doc__ = ICacheRegistration.__doc__
- implements(ICacheConfiguration)
+ implements(ICacheRegistration)
serviceType = 'Caching'
- status = ConfigurationStatusProperty()
+ status = RegistrationStatusProperty()
label = "Cache"
@@ -120,3 +117,7 @@
def getInterface(self):
return ICache
+
+
+# XXX Pickle backward compatability
+CacheConfiguration = CacheRegistration
=== Zope3/src/zope/app/services/configure.zcml 1.37 => 1.38 ===
--- Zope3/src/zope/app/services/configure.zcml:1.37 Thu Jun 12 05:34:43 2003
+++ Zope3/src/zope/app/services/configure.zcml Sat Jun 21 17:22:12 2003
@@ -3,13 +3,13 @@
xmlns:fssync='http://namespaces.zope.org/fssync'
>
-<!-- Configuration registries -->
+<!-- Registration registries -->
-<content class="zope.app.services.configuration.ConfigurationRegistry">
+<content class="zope.app.services.registration.RegistrationStack">
<require
permission="zope.ManageServices"
interface=
- "zope.app.interfaces.services.configuration.IConfigurationRegistry"
+ "zope.app.interfaces.services.registration.IRegistrationStack"
/>
</content>
@@ -22,16 +22,16 @@
/>
<require
permission="zope.ManageServices"
- interface="zope.app.interfaces.services.configuration.IConfigurable"
+ interface="zope.app.interfaces.services.registration.IRegistry"
attributes="getRegisteredMatching"
/>
</content>
-<content class="zope.app.services.adapter.AdapterConfiguration">
+<content class="zope.app.services.adapter.AdapterRegistration">
<require
permission="zope.ManageServices"
- interface="zope.app.interfaces.services.adapter.IAdapterConfiguration"
- set_schema="zope.app.interfaces.services.configuration.IConfiguration"
+ interface="zope.app.interfaces.services.adapter.IAdapterRegistration"
+ set_schema="zope.app.interfaces.services.registration.IRegistration"
/>
<require
permission="zope.ManageServices"
@@ -48,16 +48,16 @@
/>
<require
permission="zope.ManageServices"
- interface="zope.app.interfaces.services.configuration.IConfigurable"
+ interface="zope.app.interfaces.services.registration.IRegistry"
attributes="getRegisteredMatching"
/>
</content>
-<content class="zope.app.services.view.ViewConfiguration">
+<content class="zope.app.services.view.ViewRegistration">
<require
permission="zope.ManageServices"
- interface="zope.app.interfaces.services.view.IViewConfiguration"
- set_schema="zope.app.interfaces.services.configuration.IConfiguration"
+ interface="zope.app.interfaces.services.view.IViewRegistration"
+ set_schema="zope.app.interfaces.services.registration.IRegistration"
/>
<require
permission="zope.ManageServices"
@@ -65,11 +65,11 @@
/>
</content>
-<content class="zope.app.services.view.PageConfiguration">
+<content class="zope.app.services.view.PageRegistration">
<require
permission="zope.ManageServices"
- interface="zope.app.interfaces.services.view.IPageConfiguration"
- set_schema="zope.app.interfaces.services.view.IPageConfiguration"
+ interface="zope.app.interfaces.services.view.IPageRegistration"
+ set_schema="zope.app.interfaces.services.view.IPageRegistration"
/>
<require
permission="zope.ManageServices"
@@ -122,9 +122,9 @@
/>
<adapter
- for="zope.app.interfaces.services.configuration.IUseConfigurable"
- provides="zope.app.interfaces.services.configuration.IUseConfiguration"
- factory="zope.app.services.configuration.UseConfiguration"
+ for="zope.app.interfaces.services.registration.IRegisterable"
+ provides="zope.app.interfaces.services.registration.IRegistered"
+ factory="zope.app.services.registration.Registered"
/>
<!-- Role Templates -->
@@ -177,20 +177,20 @@
<require
permission="zope.View"
interface="zope.app.interfaces.cache.cache.ICachingService"
- attributes="queryConfigurations queryConfigurationsFor
- listConfigurationNames" />
+ attributes="queryRegistrations queryRegistrationsFor
+ listRegistrationNames" />
<require
permission="zope.ManageServices"
interface="zope.app.interfaces.container.IContainer" />
</content>
- <content class="zope.app.services.cache.CacheConfiguration">
+ <content class="zope.app.services.cache.CacheRegistration">
<require
permission="zope.ManageServices"
- interface="zope.app.interfaces.services.cache.ICacheConfiguration"
+ interface="zope.app.interfaces.services.cache.ICacheRegistration"
set_attributes="name componentPath permission"
set_schema=
- "zope.app.interfaces.services.configuration.IConfiguration" />
+ "zope.app.interfaces.services.registration.IRegistration" />
<require
permission="zope.ManageServices"
interface="zope.app.interfaces.container.IAddNotifiable" />
@@ -213,13 +213,13 @@
interface="zope.app.interfaces.annotation.IAttributeAnnotatable" />
</content>
- <content class="zope.app.services.service.ServiceConfiguration">
+ <content class="zope.app.services.service.ServiceRegistration">
<require
permission="zope.ManageServices"
- interface="zope.app.interfaces.services.service.IServiceConfiguration"
+ interface="zope.app.interfaces.services.service.IServiceRegistration"
set_attributes="serviceType componentPath permission"
set_schema=
- "zope.app.interfaces.services.configuration.IConfiguration"
+ "zope.app.interfaces.services.registration.IRegistration"
/>
<require
permission="zope.ManageServices"
@@ -257,20 +257,20 @@
<require
permission="zope.ManageServices"
interface="zope.app.interfaces.container.IWriteContainer"
- attributes="getConfigurationManager"
+ attributes="getRegistrationManager"
/>
<implements
interface="zope.app.interfaces.annotation.IAttributeAnnotatable" />
</content>
-<!-- Configuration Manager -->
+<!-- Registration Manager -->
- <content class="zope.app.services.configuration.ConfigurationManager">
+ <content class="zope.app.services.registration.RegistrationManager">
<factory
- id = "zope.app.services.ConfigurationManager"
+ id = "zope.app.services.RegistrationManager"
permission = "zope.ManageServices"
- title = "Configuration Manager" />
+ title = "Registration Manager" />
<require
permission="zope.View"
interface="zope.app.interfaces.container.IReadContainer" />
@@ -278,7 +278,7 @@
permission="zope.ManageServices"
interface="
zope.app.interfaces.container.IWriteContainer
- zope.app.interfaces.services.configuration.IOrderedContainer
+ zope.app.interfaces.services.registration.IOrderedContainer
zope.app.interfaces.container.IDeleteNotifiable
"
/>
@@ -319,7 +319,7 @@
interface="zope.app.interfaces.container.IWriteContainer
zope.app.interfaces.services.pagefolder.IPageFolderInfo"
set_schema="zope.app.interfaces.services.pagefolder.IPageFolderInfo"
- attributes="configured getConfigurationManager"
+ attributes="configured getRegistrationManager"
/>
<implements
interface="zope.app.interfaces.annotation.IAttributeAnnotatable" />
@@ -341,17 +341,17 @@
<require
permission="zope.View"
interface="zope.app.interfaces.rdb.IConnectionService"
- attributes="queryConfigurations queryConfigurationsFor
- listConfigurationNames" />
+ attributes="queryRegistrations queryRegistrationsFor
+ listRegistrationNames" />
</content>
- <content class="zope.app.services.connection.ConnectionConfiguration">
+ <content class="zope.app.services.connection.ConnectionRegistration">
<require
permission="zope.ManageServices"
interface=
- "zope.app.interfaces.services.connection.IConnectionConfiguration"
+ "zope.app.interfaces.services.connection.IConnectionRegistration"
set_attributes="name componentPath"
- set_schema="zope.app.interfaces.services.view.IPageConfiguration"
+ set_schema="zope.app.interfaces.services.view.IPageRegistration"
/>
<require
permission="zope.ManageServices"
@@ -488,7 +488,7 @@
<!-- Filesystem synchronization support -->
<fssync:adapter
- class=".configuration.ConfigurationManager"
+ class=".registration.RegistrationManager"
factory="zope.app.content.fssync.DirectoryAdapter"
/>
@@ -518,23 +518,23 @@
/>
<fssync:adapter
- class=".cache.CacheConfiguration"
- factory=".configuration.ComponentConfigurationAdapter"
+ class=".cache.CacheRegistration"
+ factory=".registration.ComponentRegistrationAdapter"
/>
<fssync:adapter
- class=".connection.ConnectionConfiguration"
- factory=".configuration.ComponentConfigurationAdapter"
+ class=".connection.ConnectionRegistration"
+ factory=".registration.ComponentRegistrationAdapter"
/>
<fssync:adapter
- class=".service.ServiceConfiguration"
- factory=".configuration.ComponentConfigurationAdapter"
+ class=".service.ServiceRegistration"
+ factory=".registration.ComponentRegistrationAdapter"
/>
<fssync:adapter
- class=".utility.UtilityConfiguration"
- factory=".configuration.ComponentConfigurationAdapter"
+ class=".utility.UtilityRegistration"
+ factory=".registration.ComponentRegistrationAdapter"
/>
<adapter
=== Zope3/src/zope/app/services/connection.py 1.14 => 1.15 ===
--- Zope3/src/zope/app/services/connection.py:1.14 Thu Jun 19 17:55:45 2003
+++ Zope3/src/zope/app/services/connection.py Sat Jun 21 17:22:12 2003
@@ -23,10 +23,10 @@
from zope.app.interfaces.services.service import ISimpleService
from zope.app.component.nextservice import queryNextService
-from zope.app.services.configuration import NameComponentConfigurable
+from zope.app.services.registration import NameComponentRegistry
from zope.interface import implements
-class ConnectionService(Persistent, NameComponentConfigurable):
+class ConnectionService(Persistent, NameComponentRegistry):
__doc__ = ILocalConnectionService.__doc__
@@ -56,8 +56,8 @@
def getAvailableConnections(self):
'See IConnectionService'
connections = {}
- for name in self.listConfigurationNames():
- registry = self.queryConfigurations(name)
+ for name in self.listRegistrationNames():
+ registry = self.queryRegistrations(name)
if registry.active() is not None:
connections[name] = 0
service = queryNextService(self, "SQLDatabaseConnections")
@@ -73,21 +73,25 @@
getAvailableConnections = ContextMethod(getAvailableConnections)
-from zope.app.interfaces.services.connection import IConnectionConfiguration
-from zope.app.services.configuration import NamedComponentConfiguration
-from zope.app.services.configuration import ConfigurationStatusProperty
+from zope.app.interfaces.services.connection import IConnectionRegistration
+from zope.app.services.registration import NamedComponentRegistration
+from zope.app.services.registration import RegistrationStatusProperty
-class ConnectionConfiguration(NamedComponentConfiguration):
+class ConnectionRegistration(NamedComponentRegistration):
- __doc__ = IConnectionConfiguration.__doc__
+ __doc__ = IConnectionRegistration.__doc__
- implements(IConnectionConfiguration)
+ implements(IConnectionRegistration)
serviceType = 'SQLDatabaseConnections'
- status = ConfigurationStatusProperty()
+ status = RegistrationStatusProperty()
label = "Connection"
def getInterface(self):
return IZopeDatabaseAdapter
+
+
+# XXX Pickle backward compatability
+ConnectionConfiguration = ConnectionRegistration
=== Zope3/src/zope/app/services/factories.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/services/factories.py:1.2 Mon Jun 16 12:47:51 2003
+++ Zope3/src/zope/app/services/factories.py Sat Jun 21 17:22:12 2003
@@ -11,10 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""A collection of factory functions for various configuration classes.
+"""A collection of factory functions for various registration classes.
-See method factory() in class ComponentConfigurationAdapter in file
-configuration.py.
+See method factory() in class ComponentRegistrationAdapter in file
+registration.py.
The functions here may create invalid objects; a subsequent setBody()
call to the adapter's setBody() method will make the object valid.
@@ -22,18 +22,18 @@
$Id$
"""
-def CacheConfiguration():
- from zope.app.services.cache import CacheConfiguration
- return CacheConfiguration("", "") # name, componentPath
-
-def ConnectionConfiguration():
- from zope.app.services.connection import ConnectionConfiguration
- return ConnectionConfiguration("", "") # name, componentPath
-
-def ServiceConfiguration():
- from zope.app.services.service import ServiceConfiguration
- return ServiceConfiguration("", "") # name, componentPath
-
-def UtilityConfiguration():
- from zope.app.services.utility import UtilityConfiguration
- return UtilityConfiguration("", None, "") # name, interface, componentPath
+def CacheRegistration():
+ from zope.app.services.cache import CacheRegistration
+ return CacheRegistration("", "") # name, componentPath
+
+def ConnectionRegistration():
+ from zope.app.services.connection import ConnectionRegistration
+ return ConnectionRegistration("", "") # name, componentPath
+
+def ServiceRegistration():
+ from zope.app.services.service import ServiceRegistration
+ return ServiceRegistration("", "") # name, componentPath
+
+def UtilityRegistration():
+ from zope.app.services.utility import UtilityRegistration
+ return UtilityRegistration("", None, "") # name, interface, componentPath
=== Zope3/src/zope/app/services/folder.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/services/folder.py:1.10 Tue Jun 3 10:17:10 2003
+++ Zope3/src/zope/app/services/folder.py Sat Jun 21 17:22:12 2003
@@ -11,7 +11,7 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""A package contains components and component configurations.
+"""A package contains components and component registrations.
$Id$
"""
@@ -24,13 +24,13 @@
from zope.app.interfaces.services.folder import ISiteManagementFolder
from zope.app.interfaces.services.service import IComponentManager
from zope.app.interfaces.file import IDirectoryFactory
-from zope.app.services.configuration import ConfigurationManagerContainer
+from zope.app.services.registration import RegistrationManagerContainer
from zope.app.traversing import getPath
from zope.app.context import ContextWrapper
from zope.context import ContextMethod
from zope.interface import implements
-class SiteManagementFolder(ConfigurationManagerContainer, BTreeContainer):
+class SiteManagementFolder(RegistrationManagerContainer, BTreeContainer):
implements(ISiteManagementFolder)
=== Zope3/src/zope/app/services/pagefolder.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/services/pagefolder.py:1.10 Thu Jun 5 08:03:17 2003
+++ Zope3/src/zope/app/services/pagefolder.py Sat Jun 21 17:22:12 2003
@@ -13,7 +13,7 @@
##############################################################################
"""Page Folders
-Page folders support easy creation and configuration of page views
+Page folders support easy creation and registration of page views
using folders of templates.
$Id$
@@ -27,18 +27,18 @@
from zope.app.traversing import getPath
from zope.app.context import getItem
from zope.context import ContextMethod
-from zope.app.interfaces.services.configuration import Active
-from zope.app.services.configuration import ConfigurationManagerContainer
+from zope.app.interfaces.services.registration import ActiveStatus
+from zope.app.services.registration import RegistrationManagerContainer
from zope.proxy import removeAllProxies
-from zope.app.services.view import PageConfiguration
+from zope.app.services.view import PageRegistration
from zope.app.interfaces.services.pagefolder import IPageFolder
-from zope.app.interfaces.services.configuration import IConfigurationManager
+from zope.app.interfaces.services.registration import IRegistrationManager
from zope.app.interfaces.file import IDirectoryFactory
from zope.app.fssync.classes import ObjectEntryAdapter, AttrMapping
from zope.app.interfaces.fssync import IObjectDirectory
from zope.interface import implements
-class PageFolder(ConfigurationManagerContainer, BTreeContainer):
+class PageFolder(RegistrationManagerContainer, BTreeContainer):
implements(IPageFolder)
@@ -51,7 +51,7 @@
template = None
def setObject(self, name, object):
- if (IConfigurationManager.isImplementedBy(object) or
+ if (IRegistrationManager.isImplementedBy(object) or
IZPTTemplate.isImplementedBy(object)):
return super(PageFolder, self).setObject(name, object)
else:
@@ -63,10 +63,10 @@
)
def activated(self):
- "See IConfiguration"
+ "See IRegistration"
def deactivated(self):
- "See IConfiguration"
+ "See IRegistration"
_attrNames = (
@@ -107,7 +107,7 @@
if IZPTTemplate.isImplementedBy(object):
template = getItem(self, name)
template = getPath(template)
- config = PageConfiguration(
+ config = PageRegistration(
forInterface=self.forInterface,
viewName=name,
permission=self.permission,
@@ -115,10 +115,10 @@
template=template,
layer=self.layer,
)
- configure = self.getConfigurationManager()
+ configure = self.getRegistrationManager()
id = configure.setObject('', config)
config = getItem(configure, id)
- config.status = Active
+ config.status = ActiveStatus
return name
=== Zope3/src/zope/app/services/service.py 1.25 => 1.26 ===
--- Zope3/src/zope/app/services/service.py:1.25 Thu Jun 19 17:55:45 2003
+++ Zope3/src/zope/app/services/service.py Sat Jun 21 17:22:12 2003
@@ -46,28 +46,28 @@
from zope.app.interfaces.container import IContainer
from zope.app.interfaces.services.service import IBindingAware
from zope.app.interfaces.services.module import IModuleService
-from zope.app.interfaces.services.service import IServiceConfiguration
+from zope.app.interfaces.services.service import IServiceRegistration
from zope.app.interfaces.services.service import IServiceManager
# Declare a tuple of all types we consider to be modules
# (used as 2nd argument to isinstance() in method resolve() below)
ModuleType = type(IModuleService), PersistentModule
-from zope.app.services.configuration import ConfigurationStatusProperty
-from zope.app.services.configuration import NameComponentConfigurable
-from zope.app.services.configuration import NamedComponentConfiguration
+from zope.app.services.registration import RegistrationStatusProperty
+from zope.app.services.registration import NameComponentRegistry
+from zope.app.services.registration import NamedComponentRegistration
from zope.app.services.folder import SiteManagementFolders
from zope.app.interfaces.services.service import ILocalService
from zope.app.traversing import getPath
-class ServiceManager(PersistentModuleRegistry, NameComponentConfigurable):
+class ServiceManager(PersistentModuleRegistry, NameComponentRegistry):
implements(IServiceManager, IContainer, IModuleService)
def __init__(self):
PersistentModuleRegistry.__init__(self)
- NameComponentConfigurable.__init__(self)
+ NameComponentRegistry.__init__(self)
self.Packages = SiteManagementFolders()
def getServiceDefinitions(wrapped_self):
@@ -295,20 +295,20 @@
resolve = ContextMethod(resolve)
-class ServiceConfiguration(NamedComponentConfiguration):
+class ServiceRegistration(NamedComponentRegistration):
- __doc__ = IServiceConfiguration.__doc__
+ __doc__ = IServiceRegistration.__doc__
- implements(IServiceConfiguration)
+ implements(IServiceRegistration)
serviceType = 'Services'
- status = ConfigurationStatusProperty()
+ status = RegistrationStatusProperty()
label = "Service"
def __init__(self, name, path, context=None):
- super(ServiceConfiguration, self).__init__(name, path)
+ super(ServiceRegistration, self).__init__(name, path)
if context is not None:
# Check that the object implements stuff we need
wrapped_self = ContextWrapper(self, context)
@@ -342,6 +342,9 @@
return self.name + " Service"
+# XXX Pickle backward compatability
+ServiceConfiguration = ServiceRegistration
+
# Fssync stuff
from zope.app.fssync.classes import AttrMapping
@@ -349,7 +352,7 @@
_smattrs = (
'_modules', # PersistentModuleRegistry
- '_bindings', # NameComponentConfigurable
+ '_bindings', # NameComponentRegistry
)
class ServiceManagerAdapter(DirectoryAdapter):
=== Zope3/src/zope/app/services/utility.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/services/utility.py:1.10 Thu Jun 19 17:55:45 2003
+++ Zope3/src/zope/app/services/utility.py Sat Jun 21 17:22:12 2003
@@ -21,13 +21,13 @@
from persistence.dict import PersistentDict
from persistence import Persistent
from zope.app.component.nextservice import getNextService
-from zope.app.interfaces.services.configuration import IConfigurable
+from zope.app.interfaces.services.registration import IRegistry
from zope.app.interfaces.services.service import ISimpleService
-from zope.app.interfaces.services.utility import IUtilityConfiguration
+from zope.app.interfaces.services.utility import IUtilityRegistration
from zope.app.interfaces.services.utility import ILocalUtilityService
-from zope.app.services.configuration import ConfigurationRegistry
-from zope.app.services.configuration import ConfigurationStatusProperty
-from zope.app.services.configuration import ComponentConfiguration
+from zope.app.services.registration import RegistrationStack
+from zope.app.services.registration import RegistrationStatusProperty
+from zope.app.services.registration import ComponentRegistration
from zope.component.exceptions import ComponentLookupError
from zope.interface.implementor import ImplementorRegistry
from zope.context import ContextMethod
@@ -35,7 +35,7 @@
class LocalUtilityService(Persistent):
- implements(ILocalUtilityService, IConfigurable, ISimpleService)
+ implements(ILocalUtilityService, IRegistry, ISimpleService)
def __init__(self):
self._utilities = PersistentDict()
@@ -48,52 +48,52 @@
getUtility = ContextMethod(getUtility)
def queryUtility(self, interface, default=None, name=''):
- registry = self.queryConfigurations(name, interface)
- if registry is not None:
- configuration = registry.active()
- if configuration is not None:
- return configuration.getComponent()
+ stack = self.queryRegistrations(name, interface)
+ if stack is not None:
+ registration = stack.active()
+ if registration is not None:
+ return registration.getComponent()
next = getNextService(self, "Utilities")
return next.queryUtility(interface, default, name)
queryUtility = ContextMethod(queryUtility)
- def queryConfigurationsFor(self, configuration, default=None):
- return self.queryConfigurations(configuration.name,
- configuration.interface,
+ def queryRegistrationsFor(self, registration, default=None):
+ return self.queryRegistrations(registration.name,
+ registration.interface,
default)
- queryConfigurationsFor = ContextMethod(queryConfigurationsFor)
+ queryRegistrationsFor = ContextMethod(queryRegistrationsFor)
- def queryConfigurations(self, name, interface, default=None):
+ def queryRegistrations(self, name, interface, default=None):
utilities = self._utilities.get(name)
if utilities is None:
return default
- registry = utilities.getRegistered(interface)
- if registry is None:
+ stack = utilities.getRegistered(interface)
+ if stack is None:
return default
- return ContextWrapper(registry, self)
- queryConfigurations = ContextMethod(queryConfigurations)
+ return ContextWrapper(stack, self)
+ queryRegistrations = ContextMethod(queryRegistrations)
- def createConfigurationsFor(self, configuration):
- return self.createConfigurations(configuration.name,
- configuration.interface)
+ def createRegistrationsFor(self, registration):
+ return self.createRegistrations(registration.name,
+ registration.interface)
- createConfigurationsFor = ContextMethod(createConfigurationsFor)
+ createRegistrationsFor = ContextMethod(createRegistrationsFor)
- def createConfigurations(self, name, interface):
+ def createRegistrations(self, name, interface):
utilities = self._utilities.get(name)
if utilities is None:
utilities = ImplementorRegistry(PersistentDict())
self._utilities[name] = utilities
- registry = utilities.getRegistered(interface)
- if registry is None:
- registry = ConfigurationRegistry()
- utilities.register(interface, registry)
+ stack = utilities.getRegistered(interface)
+ if stack is None:
+ stack = RegistrationStack()
+ utilities.register(interface, stack)
- return ContextWrapper(registry, self)
- createConfigurations = ContextMethod(createConfigurations)
+ return ContextWrapper(stack, self)
+ createRegistrations = ContextMethod(createRegistrations)
def getRegisteredMatching(self):
L = []
@@ -106,35 +106,39 @@
getRegisteredMatching = ContextMethod(getRegisteredMatching)
-class UtilityConfiguration(ComponentConfiguration):
- """Utility component configuration for persistent components
+class UtilityRegistration(ComponentRegistration):
+ """Utility component registration for persistent components
- This configuration configures persistent components in packages to
+ This registration configures persistent components in packages to
be utilities.
"""
serviceType = 'Utilities'
- status = ConfigurationStatusProperty()
+ status = RegistrationStatusProperty()
- implements(IUtilityConfiguration)
+ implements(IUtilityRegistration)
def __init__(self, name, interface, component_path, permission=None):
- ComponentConfiguration.__init__(self, component_path, permission)
+ ComponentRegistration.__init__(self, component_path, permission)
self.name = name
self.interface = interface
def usageSummary(self):
- # Override IConfiguration.usageSummary()
+ # Override IRegistration.usageSummary()
s = "%s utility" % self.interface.__name__
if self.name:
s += " named %s" % self.name
return s
def getInterface(self):
- # ComponentConfiguration calls this when you specify a
+ # ComponentRegistration calls this when you specify a
# permission; it needs the interface to create a security
# proxy for the interface with the given permission.
# XXX Smells like a dead chicken to me.
return self.interface
+
+
+# XXX Pickle backward compatability
+UtilityConfiguration = UtilityRegistration
=== Zope3/src/zope/app/services/utility.zcml 1.3 => 1.4 ===
--- Zope3/src/zope/app/services/utility.zcml:1.3 Thu Apr 3 17:05:34 2003
+++ Zope3/src/zope/app/services/utility.zcml Sat Jun 21 17:22:12 2003
@@ -7,17 +7,17 @@
/>
<require
permission="zope.ManageServices"
- attributes="getRegisteredMatching queryConfigurations"
+ attributes="getRegisteredMatching queryRegistrations"
/>
</content>
-<content class=".utility.UtilityConfiguration">
+<content class=".utility.UtilityRegistration">
<require
permission="zope.ManageServices"
- interface="zope.app.interfaces.services.utility.IUtilityConfiguration
+ interface="zope.app.interfaces.services.utility.IUtilityRegistration
zope.app.interfaces.container.IAddNotifiable
zope.app.interfaces.container.IDeleteNotifiable"
- set_schema="zope.app.interfaces.services.utility.IUtilityConfiguration"
+ set_schema="zope.app.interfaces.services.utility.IUtilityRegistration"
/>
</content>
=== Zope3/src/zope/app/services/view.py 1.23 => 1.24 ===
--- Zope3/src/zope/app/services/view.py:1.23 Thu Jun 19 17:55:45 2003
+++ Zope3/src/zope/app/services/view.py Sat Jun 21 17:22:12 2003
@@ -24,12 +24,12 @@
from zope.component.interfaces import IViewService
from zope.component.exceptions import ComponentLookupError
from zope.component import getServiceManager
-from zope.app.interfaces.services.configuration import IConfigurable
-from zope.app.services.configuration import ConfigurationRegistry
-from zope.app.services.configuration import SimpleConfiguration
+from zope.app.interfaces.services.registration import IRegistry
+from zope.app.services.registration import RegistrationStack
+from zope.app.services.registration import SimpleRegistration
from zope.app.context import ContextWrapper
from zope.context import ContextMethod
-from zope.app.services.configuration import ConfigurationStatusProperty
+from zope.app.services.registration import RegistrationStatusProperty
from zope.app.component.nextservice import getNextService
from zope.component import getSkin
from zope.interface import implements
@@ -40,29 +40,29 @@
from zope.app.traversing import getRoot, traverse
from zope.exceptions import NotFoundError
-from zope.app.interfaces.services.view import IViewConfiguration
-from zope.app.interfaces.services.view import IPageConfiguration
+from zope.app.interfaces.services.view import IViewRegistration
+from zope.app.interfaces.services.view import IPageRegistration
from zope.app.services.adapter import PersistentAdapterRegistry
from zope.configuration.exceptions import ConfigurationError
from zope.app.interfaces.services.service import ISimpleService
class ViewService(Persistent):
- implements(IViewService, IConfigurable, ISimpleService)
+ implements(IViewService, IRegistry, ISimpleService)
def __init__(self):
self._layers = PersistentDict()
- def queryConfigurationsFor(self, configuration, default=None):
- "See IConfigurable"
- return self.queryConfigurations(
- configuration.viewName, configuration.layer,
- configuration.forInterface, configuration.presentationType,
+ def queryRegistrationsFor(self, registration, default=None):
+ "See IRegistry"
+ return self.queryRegistrations(
+ registration.viewName, registration.layer,
+ registration.forInterface, registration.presentationType,
default)
- queryConfigurationsFor = ContextMethod(queryConfigurationsFor)
+ queryRegistrationsFor = ContextMethod(queryRegistrationsFor)
- def queryConfigurations(self, name, layer,
+ def queryRegistrations(self, name, layer,
forInterface, presentationType, default=None):
names = self._layers.get(layer)
@@ -81,17 +81,17 @@
return ContextWrapper(registry, self)
- queryConfigurations = ContextMethod(queryConfigurations)
+ queryRegistrations = ContextMethod(queryRegistrations)
- def createConfigurationsFor(self, configuration):
- "See IConfigurable"
- return self.createConfigurations(
- configuration.viewName, configuration.layer,
- configuration.forInterface, configuration.presentationType)
+ def createRegistrationsFor(self, registration):
+ "See IRegistry"
+ return self.createRegistrations(
+ registration.viewName, registration.layer,
+ registration.forInterface, registration.presentationType)
- createConfigurationsFor = ContextMethod(createConfigurationsFor)
+ createRegistrationsFor = ContextMethod(createRegistrationsFor)
- def createConfigurations(self,
+ def createRegistrations(self,
viewName, layer, forInterface, presentationType):
names = self._layers.get(layer)
@@ -108,12 +108,12 @@
forInterface, presentationType)
if registry is None:
- registry = ConfigurationRegistry()
+ registry = RegistrationStack()
adapter_registry.register(forInterface, presentationType, registry)
return ContextWrapper(registry, self)
- createConfigurations = ContextMethod(createConfigurations)
+ createRegistrations = ContextMethod(createRegistrations)
def getView(self, object, name, request):
view = self.queryView(object, name, request)
@@ -215,13 +215,13 @@
return result
-class ViewConfiguration(SimpleConfiguration):
+class ViewRegistration(SimpleRegistration):
- implements(IViewConfiguration)
+ implements(IViewRegistration)
serviceType = 'Views'
- status = ConfigurationStatusProperty()
+ status = RegistrationStatusProperty()
_what = "View" # For usageSummary(); subclass may override
@@ -250,9 +250,9 @@
s = "%s in layer %s" % (s, self.layer)
return s
-class PageConfiguration(ViewConfiguration):
+class PageRegistration(ViewRegistration):
- implements(IPageConfiguration)
+ implements(IPageRegistration)
# We only care about browser pages
presentationType = IBrowserPresentation
@@ -264,7 +264,7 @@
class_=None, template=None, attribute=None,
layer='default'):
- super(PageConfiguration, self).__init__(
+ super(PageRegistration, self).__init__(
forInterface, viewName, self.presentationType,
class_, permission, layer)
@@ -289,19 +289,19 @@
def validate(self):
if self.template and self.attribute:
raise ConfigurationError(
- "PageConfiguration for %s view name %s: "
+ "PageRegistration for %s view name %s: "
"Cannot have both 'template' and 'attribute' at the same time." %
(self.forInterface, self.viewName))
if not self.template and not self.attribute:
raise ConfigurationError(
- "PageConfiguration for %s view name %s: "
+ "PageRegistration for %s view name %s: "
"Should have a 'template' or 'attribute' attribute." %
(self.forInterface, self.viewName))
if not self.class_ and self.attribute:
raise ConfigurationError(
- "PageConfiguration for %s view name %s: "
+ "PageRegistration for %s view name %s: "
"Cannot have an 'attribute' without a 'class_'." %
(self.forInterface, self.viewName))
@@ -335,7 +335,6 @@
getView = ContextMethod(getView)
-
class DefaultClass:
def __init__(self, context, request):
@@ -352,3 +351,8 @@
if not template_usage:
kw["template_usage"] = template_usage
return self.template.render(self.view, *args, **kw)
+
+
+# XXX Pickle backward compatability
+PageConfiguration = PageRegistration
+ViewConfiguration = ViewRegistration
=== Removed File Zope3/src/zope/app/services/configuration.py ===