Commit a7ee60b7 authored by Lucas Carvalho's avatar Lucas Carvalho

Without acquisition, restricted python seems not able to find authentication...

Without acquisition, restricted python seems not able to find authentication information, so Cache the script object using aq_base was raising Unauthorised (This is a partial revert to Revision 33676.).
 


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35662 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7e503f59
...@@ -3083,6 +3083,16 @@ class Base( CopyContainer, ...@@ -3083,6 +3083,16 @@ class Base( CopyContainer,
fallback_script_id : the script to use if nothing is found fallback_script_id : the script to use if nothing is found
""" """
def getScriptName(portal_type, method_id):
from Products.ERP5Type.Base import Base
class_name_list = [base_class.__name__ for base_class in self.__class__.mro() if issubclass(base_class, Base)]
script_name_end = '_%s' % method_id
for script_name_begin in [portal_type, self.getMetaType()] + class_name_list:
name = ''.join([script_name_begin.replace(' ',''), script_name_end])
script = getattr(self, name, None)
if script is not None:
return name
# script_id should not be used any more, keep compatibility # script_id should not be used any more, keep compatibility
if script_id is not None: if script_id is not None:
LOG('ERP5Type/Base.getTypeBaseMethod',0, LOG('ERP5Type/Base.getTypeBaseMethod',0,
...@@ -3097,22 +3107,12 @@ class Base( CopyContainer, ...@@ -3097,22 +3107,12 @@ class Base( CopyContainer,
cache_key = (portal_type, method_id) cache_key = (portal_type, method_id)
try: try:
script = type_base_cache[cache_key] name = type_base_cache[cache_key]
except KeyError: except KeyError:
class_name_list = [portal_type, self.getMetaType()] + \ name = getScriptName(portal_type, method_id)
[base_class.__name__ for base_class in self.__class__.mro() type_base_cache[cache_key] = name
if issubclass(base_class, Base)] if name is not None:
script_name_end = '_' + method_id return getattr(self, name)
for script_name_begin in class_name_list:
script_id = script_name_begin.replace(' ','') + script_name_end
script = getattr(self, script_id, None)
if script is not None:
type_base_cache[cache_key] = aq_base(script)
return script
type_base_cache[cache_key] = None
if script is not None:
return script.__of__(self)
if fallback_script_id is not None: if fallback_script_id is not None:
return getattr(self, fallback_script_id) return getattr(self, fallback_script_id)
......
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