Commit 312976df authored by Jérome Perrin's avatar Jérome Perrin

don't cache ProxyField.get_value if the target field is defined by a TALES


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16711 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 438322fb
......@@ -567,8 +567,9 @@ class ProxyField(ZMIField):
field = REQUEST.get('field__proxyfield_%s_%s' % (self.id, id), self)
REQUEST.set('field__proxyfield_%s_%s' % (proxy_field.id, id), field)
# Don't use cache if field is not stored in zodb.
if self._p_oid is None:
# Don't use cache if field is not stored in zodb, or if target field is
# defined by a TALES
if self._p_oid is None or self.tales['field_id'] or self.tales['form_id']:
return self._get_value(id, **kw)
cache_id = ('ProxyField.get_value',
......
......@@ -30,6 +30,7 @@ import unittest
# Make it possible to use Globals.get_request
class DummyRequest(dict):
__allow_access_to_unprotected_subobjects__ = 1
def set(self, k, v):
self[k] = v
......@@ -226,6 +227,26 @@ class TestProxyField(unittest.TestCase):
field_id='my_title',))
self.assertEquals('Base_view', proxy_field.get_value('title'))
def test_get_value_cache_on_TALES_target(self):
# If the proxy field defines its target using TALES, then no caching should
# happen.
original_field = self.addField(self.container.Base_viewProxyFieldLibrary,
'my_title', 'Title', 'StringField')
other_field = self.addField(self.container.Base_viewProxyFieldLibrary,
'my_other_field', 'Other', 'StringField')
proxy_field = self.addField(self.container.Base_view,
'my_id', 'ID', 'ProxyField')
proxy_field.manage_edit_xmlrpc(dict(form_id='Base_viewProxyFieldLibrary'))
proxy_field.manage_tales_xmlrpc(dict(field_id='request/field_id'))
self.container.REQUEST.set('field_id', 'my_title')
self.assertEquals(original_field, proxy_field.getTemplateField())
self.assertEquals('Title', proxy_field.get_value('title'))
self.container.REQUEST.set('field_id', 'my_other_field')
self.assertEquals(other_field, proxy_field.getTemplateField())
self.assertEquals('Other', proxy_field.get_value('title'))
class TestFieldValueCache(unittest.TestCase):
"""Tests field value caching system
......
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