Commit b61103a5 authored by Arnaud Fontaine's avatar Arnaud Fontaine

zope4py3: Unauthorized() was always raised preventing access to ZMI.

Error `Using import with a level specification isn't supported by AccessControl: AccessControl`:
    eggs/Zope-4.5.3+slapospatched002-py3.7.egg/Products/PageTemplates/Expressions.py(188)_eval()
  -> ob = self._subexprs[-1](econtext)
    eggs/zope.tales-5.1-py3.7.egg/zope/tales/expressions.py(153)_eval()
  -> ob = self._traverser(ob, element, econtext)
    eggs/Zope-4.5.3+slapospatched002-py3.7.egg/Products/PageTemplates/Expressions.py(84)boboAwareZopeTraverse()
  -> request=request)
    eggs/zope.traversing-4.4.1-py3.7.egg/zope/traversing/adapters.py(156)traversePathElement()
  -> return traversable.traverse(nm, further_path)
    eggs/zope.traversing-4.4.1-py3.7.egg/zope/traversing/adapters.py(58)traverse()
  -> return subject[name]
    eggs/Zope-4.5.3+slapospatched002-py3.7.egg/Products/PageTemplates/ZRPythonExpr.py(56)__getitem__()
  -> mod = safe_builtins['__import__'](module)
    parts/erp5/product/ERP5Type/patches/Restricted.py(451)guarded_import()
  -> return orig_guarded_import(mname, globals, locals, fromlist, level)
    eggs/AccessControl-4.2-py3.7-linux-x86_64.egg/AccessControl/ZopeGuards.py(410)guarded_import()
  -> "supported by AccessControl: %s" % mname)
parent 5fc2104c
......@@ -422,8 +422,12 @@ for alias, real in list(MNAME_MAP.items()):
allow_module(real)
del alias, real
orig_guarded_import = safe_builtins['__import__']
try:
from AccessControl.ZopeGuards import import_default_level # zope4py3
except ImportError:
import_default_level = -1
def guarded_import(mname, globals=None, locals=None, fromlist=None,
level=-1):
level=import_default_level):
for fromname in fromlist or ():
if fromname[:1] == '_':
raise Unauthorized(fromname)
......
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