[Zope3-checkins] CVS: Zope3/src/zope/app/cache -
annotationcacheable.py:1.4 caching.py:1.5 configure.zcml:1.5
ram.py:1.8
Stephan Richter
srichter at cosmos.phy.tufts.edu
Tue Aug 19 14:34:44 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/cache
In directory cvs.zope.org:/tmp/cvs-serv19346/cache
Modified Files:
annotationcacheable.py caching.py configure.zcml ram.py
Log Message:
Just to make it worth the effort, here is the rewrite of the Caching Service
to use local utilities. I am amazed how much cruft can go away. There are
still some dead chickens left that can be easily fixed by providing a
default overview screen for these services and remodeling the local utility
service a bit.
Jim,
noone has complained about the changes yet. Are you guys at ZC having a fit
with it? I think in general people just not use these components heavily
yet and it is no big deal to create them, since their data does not contain
much programming logic (i.e. they are easily recreated) and there are only
a few around ata time usually.
=== Zope3/src/zope/app/cache/annotationcacheable.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/cache/annotationcacheable.py:1.3 Fri Jun 6 16:44:30 2003
+++ Zope3/src/zope/app/cache/annotationcacheable.py Tue Aug 19 13:34:08 2003
@@ -11,11 +11,14 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""An adapter of annotatable objects."""
+"""An adapter of annotatable objects.
-from zope.component import getAdapter, getService
+$Id$
+"""
+from zope.app import zapi
from zope.app.interfaces.annotation import IAnnotations
-from zope.app.interfaces.cache.cache import ICacheable
+from zope.app.interfaces.cache import ICacheable
+from zope.app.services.servicenames import Caching
from zope.interface import implements
annotation_key = 'zope.app.cache.CacheManager'
@@ -29,17 +32,17 @@
self._context = context
def getCacheId(self):
- annotations = getAdapter(self._context, IAnnotations)
+ annotations = zapi.getAdapter(self._context, IAnnotations)
return annotations.get(annotation_key, None)
def setCacheId(self, id):
# Remove object from old cache
old_cache_id = self.getCacheId()
if old_cache_id and old_cache_id != id:
- service = getService(self._context, "Caching")
+ service = zapi.getService(self._context, Caching)
cache = service.getCache(old_cache_id)
cache.invalidate(self._context)
- annotations = getAdapter(self._context, IAnnotations)
+ annotations = zapi.getAdapter(self._context, IAnnotations)
annotations[annotation_key] = id
cacheId = property(getCacheId, setCacheId, None, "Associated cache name")
=== Zope3/src/zope/app/cache/caching.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/cache/caching.py:1.4 Wed Mar 19 14:57:23 2003
+++ Zope3/src/zope/app/cache/caching.py Tue Aug 19 13:34:08 2003
@@ -14,7 +14,7 @@
"""Helpers for caching."""
from zope.component import getAdapter, getService, ComponentLookupError
-from zope.app.interfaces.cache.cache import ICacheable
+from zope.app.interfaces.cache import ICacheable
from zope.app.traversing import getPath
=== Zope3/src/zope/app/cache/configure.zcml 1.4 => 1.5 ===
--- Zope3/src/zope/app/cache/configure.zcml:1.4 Sun Aug 3 15:08:14 2003
+++ Zope3/src/zope/app/cache/configure.zcml Tue Aug 19 13:34:08 2003
@@ -1,30 +1,31 @@
-<configure
- xmlns='http://namespaces.zope.org/zope'
- xmlns:browser='http://namespaces.zope.org/browser'
- xmlns:event='http://namespaces.zope.org/event'
- package="zope.app.cache"
- i18n_domain="zope"
- >
-
- <serviceType id="Caching"
- interface="zope.app.interfaces.cache.cache.ICachingService"
- />
-
- <adapter factory="zope.app.cache.annotationcacheable.AnnotationCacheable"
- provides="zope.app.interfaces.cache.cache.ICacheable"
- for="zope.app.interfaces.annotation.IAnnotatable"
- />
+<configure xmlns="http://namespaces.zope.org/zope">
+ <serviceType
+ id="Caching"
+ interface="zope.app.interfaces.cache.ICachingService" />
- <content class="zope.app.cache.ram.RAMCache">
- <factory id="zope.app.caching.RAMCache"
+ <adapter
+ for="zope.app.interfaces.annotation.IAnnotatable"
+ provides="zope.app.interfaces.cache.ICacheable"
+ factory="zope.app.cache.annotationcacheable.AnnotationCacheable" />
+
+ <content class=".ram.RAMCache">
+ <factory
+ id="zope.caching.RAMCache"
permission="zope.Public" />
- <require permission="zope.Public"
- interface="zope.app.interfaces.cache.ram.IRAMCache"
- />
+
+ <implements
+ interface="zope.app.interfaces.cache.ICache" />
+
<implements
- interface="zope.app.interfaces.annotation.IAttributeAnnotatable"
- />
+ interface="zope.app.interfaces.annotation.IAttributeAnnotatable" />
+
+ <implements
+ interface="zope.app.interfaces.services.utility.ILocalUtility" />
+
+ <require
+ permission="zope.Public"
+ interface="zope.app.interfaces.cache.ram.IRAMCache" />
</content>
</configure>
=== Zope3/src/zope/app/cache/ram.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/cache/ram.py:1.7 Sat Jun 21 17:22:09 2003
+++ Zope3/src/zope/app/cache/ram.py Tue Aug 19 13:34:08 2003
@@ -15,16 +15,14 @@
$Id$
"""
-
from time import time
from thread import allocate_lock
from pickle import dumps
-
from persistence import Persistent
from zope.app.interfaces.cache.ram import IRAMCache
+from zope.app.interfaces.cache import ICache
from zope.app.interfaces.event import IObjectModifiedEvent
-from zope.app.interfaces.services.registration import IAttributeRegisterable
from zope.interface import implements
# A global caches dictionary shared between threads
@@ -55,7 +53,7 @@
handle their blocking internally.
"""
- implements(IRAMCache, IAttributeRegisterable)
+ implements(IRAMCache)
def __init__(self):
More information about the Zope3-Checkins
mailing list