[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Caching - ICacheable.py:1.4
Viktorija Zaksiene
ryzaja@codeworks.lt
Wed, 13 Nov 2002 06:30:31 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Caching
In directory cvs.zope.org:/tmp/cvs-serv18481/lib/python/Zope/App/Caching
Modified Files:
ICacheable.py
Log Message:
ICacheable.allowed_values should not raise errors when there are no caching services
=== Zope3/lib/python/Zope/App/Caching/ICacheable.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/App/Caching/ICacheable.py:1.3 Mon Nov 11 15:57:20 2002
+++ Zope3/lib/python/Zope/App/Caching/ICacheable.py Wed Nov 13 06:30:31 2002
@@ -16,6 +16,7 @@
"""
from Interface import Interface
from Zope.ComponentArchitecture import getService
+from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
from Zope.ContextWrapper import ContextProperty
import Zope.Schema
@@ -24,10 +25,12 @@
def __allowed(self):
"""Note that this method works only if the Field is context wrapped."""
- caching_service = getService(self.context, "Caching")
-
- # FIXME: i18n
- return [''] + list(caching_service.getAvailableCaches())
+ try:
+ caching_service = getService(self.context, "Caching")
+ except ComponentLookupError:
+ return ['']
+ else:
+ return [''] + list(caching_service.getAvailableCaches())
allowed_values = ContextProperty(__allowed)