[Zope3-checkins] CVS: Zope3/src/zope/app/cache -
annotationcacheable.py:1.4.6.2 caching.py:1.5.6.2
Jim Fulton
jim at zope.com
Mon Sep 8 19:37:22 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/cache
In directory cvs.zope.org:/tmp/cvs-serv31668/src/zope/app/cache
Modified Files:
Tag: parentgeddon-branch
annotationcacheable.py caching.py
Log Message:
got more tests to pass
=== Zope3/src/zope/app/cache/annotationcacheable.py 1.4.6.1 => 1.4.6.2 ===
--- Zope3/src/zope/app/cache/annotationcacheable.py:1.4.6.1 Mon Sep 8 14:21:32 2003
+++ Zope3/src/zope/app/cache/annotationcacheable.py Mon Sep 8 18:36:51 2003
@@ -17,7 +17,7 @@
"""
from zope.app import zapi
from zope.app.interfaces.annotation import IAnnotations
-from zope.app.interfaces.cache import ICacheable, ICache
+from zope.app.interfaces.cache import ICacheable
from zope.app.services.servicenames import Caching
from zope.interface import implements
@@ -39,7 +39,8 @@
# Remove object from old cache
old_cache_id = self.getCacheId()
if old_cache_id and old_cache_id != id:
- cache = getUtility(self._context, ICache, old_cache_id)
+ service = zapi.getService(self._context, Caching)
+ cache = service.getCache(old_cache_id)
cache.invalidate(self._context)
annotations = zapi.getAdapter(self._context, IAnnotations)
annotations[annotation_key] = id
=== Zope3/src/zope/app/cache/caching.py 1.5.6.1 => 1.5.6.2 ===
--- Zope3/src/zope/app/cache/caching.py:1.5.6.1 Mon Sep 8 14:21:32 2003
+++ Zope3/src/zope/app/cache/caching.py Mon Sep 8 18:36:51 2003
@@ -13,21 +13,23 @@
##############################################################################
"""Helpers for caching."""
-from zope.app import zapi
-from zope.component import ComponentLookupError
-from zope.app.interfaces.cache import ICacheable, ICache
+from zope.component import getAdapter, getService, ComponentLookupError
+from zope.app.interfaces.cache import ICacheable
+from zope.app.traversing import getPath
+
def getCacheForObj(obj):
"""Returns the cache associated with obj or None."""
- adapter = zapi.getAdapter(obj, ICacheable)
+ adapter = getAdapter(obj, ICacheable)
cache_id = adapter.getCacheId()
if not cache_id:
return None
- return zapi.getUtility(obj, ICache, cache_id)
+ service = getService(obj, "Caching")
+ return service.getCache(cache_id)
def getLocationForCache(obj):
"""Returns the location to be used for caching the object or None."""
try:
- return zapi.getPath(obj)
+ return getPath(obj)
except (ComponentLookupError, TypeError):
return None
More information about the Zope3-Checkins
mailing list