Commit b1b9451c authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

do not store _marker value in cache, especially for the value where loads(dumps(x)) != x.

parent 95c326f3
...@@ -66,7 +66,7 @@ class PreferenceMethod(Method): ...@@ -66,7 +66,7 @@ class PreferenceMethod(Method):
self._preference_cache_id = 'PreferenceTool.CachingMethod.%s' % attribute self._preference_cache_id = 'PreferenceTool.CachingMethod.%s' % attribute
def __call__(self, instance, default=_marker, *args, **kw): def __call__(self, instance, default=_marker, *args, **kw):
def _getPreference(*args, **kw): def _getPreference(default, *args, **kw):
# XXX: sql_catalog_id is passed when calling getPreferredArchive # XXX: sql_catalog_id is passed when calling getPreferredArchive
# This is inconsistent with regular accessor API, and indicates that # This is inconsistent with regular accessor API, and indicates that
# there is a design problem in current archive API. # there is a design problem in current archive API.
...@@ -78,17 +78,14 @@ class PreferenceMethod(Method): ...@@ -78,17 +78,14 @@ class PreferenceMethod(Method):
# user to mask a non-null global value with a null value. # user to mask a non-null global value with a null value.
if value not in (_marker, None, '', (), []): if value not in (_marker, None, '', (), []):
return value return value
return _marker if default is _marker:
return self._preference_default
return default
_getPreference = CachingMethod(_getPreference, _getPreference = CachingMethod(_getPreference,
id='%s.%s' % (self._preference_cache_id, id='%s.%s' % (self._preference_cache_id,
getSecurityManager().getUser().getId()), getSecurityManager().getUser().getId()),
cache_factory='erp5_ui_short') cache_factory='erp5_ui_short')
value = _getPreference(*args, **kw) return _getPreference(default, *args, **kw)
if value is not _marker:
return value
elif default is _marker:
return self._preference_default
return default
class PreferenceTool(BaseTool): class PreferenceTool(BaseTool):
""" """
......
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