Commit 0060f8ee authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

guard dynamically generated tester and preference methods.

parent 6a2c8eba
...@@ -88,6 +88,20 @@ class PreferenceMethod(Method): ...@@ -88,6 +88,20 @@ class PreferenceMethod(Method):
cache_factory='erp5_ui_long') cache_factory='erp5_ui_long')
return _getPreference(default, *args, **kw) return _getPreference(default, *args, **kw)
class __roles__:
@staticmethod
def rolesForPermissionOn(ob):
self = ob.__self__
name = '%s__roles__' % ob.__name__
# we explictly call _aq_dynamic to prevent acquiering the attribute
# from container
roles = getattr(self.__class__, name, self)
if roles is self:
roles = self._aq_dynamic(name)
if roles is None:
return rolesForPermissionOn(None, self, ('Manager',),
'_Access_contents_information_Permission')
return getattr(roles, '__of__', lambda aq_parent: roles)(self)
class PreferenceTool(BaseTool): class PreferenceTool(BaseTool):
""" """
......
...@@ -66,3 +66,18 @@ class Accessor(Method): ...@@ -66,3 +66,18 @@ class Accessor(Method):
# Returns a reindexing alias # Returns a reindexing alias
from .Alias import ReindexAlias from .Alias import ReindexAlias
return ReindexAlias(id, self.__name__) return ReindexAlias(id, self.__name__)
class __roles__:
@staticmethod
def rolesForPermissionOn(ob):
self = ob.__self__
name = '%s__roles__' % ob.__name__
# we explictly call _aq_dynamic to prevent acquiering the attribute
# from container
roles = getattr(self.__class__, name, self)
if roles is self:
roles = self._aq_dynamic(name)
if roles is None:
return rolesForPermissionOn(None, self, ('Manager',),
'_Access_contents_information_Permission')
return getattr(roles, '__of__', lambda aq_parent: roles)(self)
...@@ -187,22 +187,6 @@ class Getter(Method): ...@@ -187,22 +187,6 @@ class Getter(Method):
psyco.bind(__call__) psyco.bind(__call__)
class __roles__:
@staticmethod
def rolesForPermissionOn(ob):
self = ob.__self__
name = '%s__roles__' % ob.__name__
# we explictly call _aq_dynamic to prevent acquiering the attribute
# from container
roles = getattr(self.__class__, name, self)
if roles is self:
roles = self._aq_dynamic(name)
if roles is None:
return rolesForPermissionOn(None, self, ('Manager',),
'_Access_contents_information_Permission')
return getattr(roles, '__of__', lambda aq_parent: roles)(self)
class Tester(Method): class Tester(Method):
""" """
Tests if an attribute value exists Tests if an attribute value exists
......
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