[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Caching - ICacheable.py:1.3
Jim Fulton
jim@zope.com
Mon, 11 Nov 2002 15:57:51 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Caching
In directory cvs.zope.org:/tmp/cvs-serv20886
Modified Files:
ICacheable.py
Log Message:
Changed the cacheName field to implement allowed_values, rather than
items and to use bound context rather than context wrappers.
Changed the cachable editing view to use a standard editing widget and
the new widget setup code in Zope.App.Forms.Utility.
Got rid of an unused import of FormView.
=== Zope3/lib/python/Zope/App/Caching/ICacheable.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/App/Caching/ICacheable.py:1.2 Wed Oct 9 09:08:44 2002
+++ Zope3/lib/python/Zope/App/Caching/ICacheable.py Mon Nov 11 15:57:20 2002
@@ -15,26 +15,29 @@
$Id$
"""
from Interface import Interface
-from Zope.ContextWrapper import ContextMethod
from Zope.ComponentArchitecture import getService
+from Zope.ContextWrapper import ContextProperty
import Zope.Schema
-class CacheName(Zope.Schema.Text):
+class CacheName(Zope.Schema.TextLine):
"""Cache Name"""
- def items(self):
+ def __allowed(self):
"""Note that this method works only if the Field is context wrapped."""
- caching_service = getService(self, "Caching")
- return [('', '(None)')] + caching_service.getAvailableCaches() # FIXME: i18n
+ caching_service = getService(self.context, "Caching")
- items = ContextMethod(items)
+ # FIXME: i18n
+ return [''] + list(caching_service.getAvailableCaches())
+
+ allowed_values = ContextProperty(__allowed)
class ICacheable(Interface):
"""Object that can be associated with a cache manager."""
- cacheId = CacheName(title=u"Cache Name",
- description=u"The name of the cache used for this object.",
- required=False)
+ cacheId = CacheName(
+ title=u"Cache Name",
+ description=u"The name of the cache used for this object.",
+ required=True)
def getCacheId():
"""Gets the associated cache manager ID."""