[Zope3-checkins] CVS: Zope3/src/zope/app/services - README.txt:1.1.2.3 field.py:1.7.2.1 utility.py:1.1.2.3 utility.zcml:1.1.2.3
Jim Fulton
jim@zope.com
Tue, 18 Mar 2003 07:35:51 -0500
Update of /cvs-repository/Zope3/src/zope/app/services
In directory cvs.zope.org:/tmp/cvs-serv19240/src/zope/app/services
Modified Files:
Tag: local-utility-branch
README.txt field.py utility.py utility.zcml
Log Message:
Checking in current code to the branch.
It may be in a state of non-working-ness. We'll fix that later.
We're currently trying to clean up the logic for adding configs.
=== Zope3/src/zope/app/services/README.txt 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/app/services/README.txt:1.1.2.2 Thu Mar 13 17:28:09 2003
+++ Zope3/src/zope/app/services/README.txt Tue Mar 18 07:35:51 2003
@@ -1,3 +1,4 @@
+==============
Local Services
==============
=== Zope3/src/zope/app/services/field.py 1.7 => 1.7.2.1 ===
--- Zope3/src/zope/app/services/field.py:1.7 Thu Mar 13 12:10:37 2003
+++ Zope3/src/zope/app/services/field.py Tue Mar 18 07:35:51 2003
@@ -25,14 +25,15 @@
from zope.app.interfaces.services.field import IComponentLocation
from zope.component import getServiceManager, getAdapter
from zope.app.interfaces.services.module import IModuleService
+from zope.interface import Interface
class ComponentPath(Field):
__implements__ = IComponentPath
- _type = unicode
+ _type = unicode # All values must be unicode strings
- def __init__(self, type, *args, **kw):
+ def __init__(self, type=None, *args, **kw):
self.type = type
super(ComponentPath, self).__init__(*args, **kw)
@@ -47,7 +48,9 @@
except NotFoundError:
raise ValidationError("Path for non-existent object", value)
- if not self.type.isImplementedBy(component):
+ if (self.type is not None and
+ (not self.type.isImplementedBy(component))
+ ):
raise ValidationError("Wrong component type", value)
class ComponentLocation(Field):
=== Zope3/src/zope/app/services/utility.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/app/services/utility.py:1.1.2.2 Thu Mar 13 17:28:09 2003
+++ Zope3/src/zope/app/services/utility.py Tue Mar 18 07:35:51 2003
@@ -17,20 +17,25 @@
$Id$
"""
-from persistence import Persistent
from persistence.dict import PersistentDict
-from zope.component.exceptions import ComponentLookupError
-from zope.proxy.context import ContextAware
-from zope.proxy.introspection import removeAllProxies
+from persistence import Persistent
from zope.app.component.nextservice import getNextService
-from zope.component.interfaces import IUtilityService
-from zope.interface.implementor import ImplementorRegistry
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.services.configuration import NamedComponentConfiguration
from zope.app.interfaces.services.service import ISimpleService
from zope.app.interfaces.services.utility import IUtilityConfiguration
+from zope.app.services.configuration import ConfigurationRegistry
+from zope.app.services.configuration import ConfigurationStatusProperty
+from zope.app.services.configuration import NamedComponentConfiguration
+from zope.app.services.configuration import SimpleConfiguration
+from zope.component.exceptions import ComponentLookupError
+from zope.component import getAdapter
+from zope.component.interfaces import IUtilityService
+from zope.interface.implementor import ImplementorRegistry
+from zope.proxy.context import ContextAware
+from zope.proxy.context import ContextWrapper
+from zope.proxy.introspection import removeAllProxies
+from zope.app.interfaces.services.configuration import IUseConfiguration
+from zope.app.traversing import getPhysicalPathString
class LocalUtilityService(Persistent, ContextAware):
@@ -56,9 +61,9 @@
return next.queryUtility(interface, default, name)
def queryConfigurationsFor(self, configuration, default=None):
- return self.queryConfiguration(configuration.name,
- configuration.interface,
- default)
+ return self.queryConfigurations(configuration.name,
+ configuration.interface,
+ default)
def queryConfigurations(self, name, interface, default=None):
utilities = self._utilities.get(name)
@@ -68,11 +73,11 @@
if registry is None:
return default
- return registry
+ return ContextWrapper(registry, self)
def createConfigurationsFor(self, configuration):
- return self.createConfiguration(configuration.name,
- configuration.interface)
+ return self.createConfigurations(configuration.name,
+ configuration.interface)
def createConfigurations(self, name, interface):
utilities = self._utilities.get(name)
@@ -85,7 +90,7 @@
registry = ConfigurationRegistry()
utilities.register(interface, registry)
- return registry
+ return ContextWrapper(registry, self)
class UtilityConfiguration(NamedComponentConfiguration):
@@ -96,14 +101,28 @@
"""
- __implements__ = IUtilityConfiguration
+ status = ConfigurationStatusProperty('Utilities')
+
+ __implements__ = (IUtilityConfiguration,
+ NamedComponentConfiguration.__implements__)
def __init__(self, name, interface, component_path, permission=None):
super(UtilityConfiguration, self).__init__(
name, component_path, permission)
self.interface = interface
+ def getInterface(self):
+ return self.interface
+
+
+ # The following hooks are called only if we implement
+ # IAddNotifiable and IDeleteNotifiable.
+
def afterAddHook(self, configuration, container):
+ """Hook method will call after an object is added to container.
+
+ Defined in IAddNotifiable.
+ """
NamedComponentConfiguration.afterAddHook(self,
configuration,
container)
@@ -112,6 +131,10 @@
adapter.addUsage(getPhysicalPathString(configuration))
def beforeDeleteHook(self, configuration, container):
+ """Hook method will call before object is removed from container.
+
+ Defined in IDeleteNotifiable.
+ """
utility = configuration.getComponent()
adapter = getAdapter(utility, IUseConfiguration)
adapter.removeUsage(getPhysicalPathString(configuration))
=== Zope3/src/zope/app/services/utility.zcml 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/app/services/utility.zcml:1.1.2.2 Thu Mar 13 17:28:09 2003
+++ Zope3/src/zope/app/services/utility.zcml Tue Mar 18 07:35:51 2003
@@ -13,6 +13,14 @@
interface="zope.app.interfaces.services.utility.IUtilityConfiguration"
set_schema="zope.app.interfaces.services.utility.IUtilityConfiguration"
/>
+ <require
+ permission="zope.ManageServices"
+ interface="zope.app.interfaces.container.IAddNotifiable"
+ />
+ <require
+ permission="zope.ManageServices"
+ interface="zope.app.interfaces.container.IDeleteNotifiable"
+ />
</content>
</zopeConfigure>