Commit 74af92fc authored by Rafael Monnerat's avatar Rafael Monnerat Committed by Xiaowu Zhang

Introduce _cacheable_key to custom cache entries per field type

  This is required by Listbox for example in order to cache per list_start.
parent 547eaeb5
......@@ -31,7 +31,7 @@ from OFS.Traversable import NotFound
from AccessControl import ClassSecurityInfo, Unauthorized
from Products.Formulator.DummyField import fields
from Products.Formulator import Widget, Validator
from Products.Formulator.Field import ZMIField
from Products.Formulator.Field import Field, ZMIField
from Products.Formulator.Errors import FormValidationError, ValidationError
from Selection import Selection, DomainSelection
from Tool.SelectionTool import createFolderMixInPageSelectionMethod
......@@ -2954,6 +2954,17 @@ class ListBox(ZMIField):
else:
return ZMIField.get_value(self, id, **kw)
def _cacheable_key(self):
selection_tool = self.getPortalObject().portal_selections
selection_name = self.get_value('selection_name')
selection = selection_tool.getSelectionFor(selection_name, REQUEST =self.REQUEST)
if selection is not None:
key = ("list_start", selection.getParams().get("list_start"))
return key
return "default"
security.declareProtected('Access contents information', 'getListMethodName')
def getListMethodName(self):
"""Return the name of the list method. If not defined, return None.
......
......@@ -761,6 +761,15 @@ class ProxyField(ZMIField):
if proxy_field is not None:
return proxy_field.get_value(id, **kw)
def _cacheable_key(self):
selection_name = self.get_value('selection_name')
if selection_name is not None:
selection_tool = self.getPortalObject().portal_selections
selection = selection_tool.getSelectionFor(selection_name, REQUEST = self.REQUEST)
if selection is not None:
return ("list_start", selection.getParams().get("list_start"))
return "default"
def _getCacheId(self):
return '%s%s' % ('ProxyField', self._p_oid or repr(self))
......
......@@ -491,6 +491,9 @@ class ZMIField(
"""The title of this field."""
return self.get_value('title')
def _cacheable_key(self):
return "default"
# display edit screen as main management screen
security.declareProtected('View management screens', 'manage_main')
manage_main = DTMLFile('dtml/fieldEdit', globals())
......@@ -721,7 +724,8 @@ class ZMIField(
keyset = {'here': self,
'value': value,
'render_prefix' : render_prefix,
'key_prefix': key_prefix}
'key_prefix': key_prefix,
'widget_keyset': self._cacheable_key()}
LOG("ZMIField.render_htmlgrid", 0, keyset)
result = self.ZCacheable_get(keywords=keyset)
if result is not None:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment