[Zope3-checkins] CVS: Zope3/src/zope/app/services - cache.py:1.7
Guido van Rossum
guido@python.org
Thu, 24 Apr 2003 17:01:26 -0400
Update of /cvs-repository/Zope3/src/zope/app/services
In directory cvs.zope.org:/tmp/cvs-serv30948/app/services
Modified Files:
cache.py
Log Message:
Improve cache object configuration. Still to do: simplify the cache
manager's main view.
=== Zope3/src/zope/app/services/cache.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/services/cache.py:1.6 Tue Mar 11 11:11:22 2003
+++ Zope3/src/zope/app/services/cache.py Thu Apr 24 17:01:26 2003
@@ -15,20 +15,25 @@
$Id$
"""
-__metaclass__ = type
from persistence import Persistent
-from zope.app.interfaces.cache.cache import ICachingService
+
+from zope.component import getAdapter, getService
+from zope.proxy.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.services.configuration import NameComponentConfigurable
-from zope.app.services.event import ServiceSubscriberEventChannel
-from zope.proxy.context import ContextMethod
+ import INameComponentConfigurable, IUseConfiguration
from zope.app.interfaces.services.event import IEventChannel
-from zope.app.interfaces.event import IObjectModifiedEvent
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.event import ServiceSubscriberEventChannel
+from zope.app.traversing import getPath
class ILocalCachingService(ICachingService, IEventChannel,
INameComponentConfigurable):
@@ -86,20 +91,6 @@
getAvailableCaches = ContextMethod(getAvailableCaches)
-
-"""A configuration for a cache.
-
-$Id$
-"""
-
-from zope.app.interfaces.services.cache import ICacheConfiguration
-from zope.app.services.configuration import NamedComponentConfiguration
-from zope.app.services.configuration import ConfigurationStatusProperty
-from zope.component import getService
-from zope.app.interfaces.event import IObjectModifiedEvent
-from zope.proxy.context import ContextMethod
-from zope.app.interfaces.cache.cache import ICache
-
class CacheConfiguration(NamedComponentConfiguration):
__doc__ = ICacheConfiguration.__doc__
@@ -129,3 +120,17 @@
def getInterface(self):
return ICache
+
+ def afterAddHook(self, configuration, container):
+ super(CacheConfiguration, self).afterAddHook(configuration,
+ container)
+ component = configuration.getComponent()
+ adapter = getAdapter(component, IUseConfiguration)
+ adapter.addUsage(getPath(configuration))
+
+ def beforeDeleteHook(self, configuration, container):
+ component = configuration.getComponent()
+ adapter = getAdapter(component, IUseConfiguration)
+ adapter.removeUsage(getPath(configuration))
+ super(CacheConfiguration, self).beforeDeleteHook(configuration,
+ container)