Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Titouan Soulard
erp5
Commits
cf1bf294
Commit
cf1bf294
authored
Mar 18, 2021
by
Aurel
Committed by
Jérome Perrin
Jan 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make patch work with Zope2
parent
4eee0f8b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
6 deletions
+22
-6
product/ERP5Type/patches/Restricted.py
product/ERP5Type/patches/Restricted.py
+22
-6
No files found.
product/ERP5Type/patches/Restricted.py
View file @
cf1bf294
...
...
@@ -16,9 +16,14 @@ import copy
import
sys
import
types
from
RestrictedPython.transformer
import
RestrictingNodeTransformer
try
:
from
RestrictedPython.transformer
import
FORBIDDEN_FUNC_NAMES
except
:
# BBB
FORBIDDEN_FUNC_NAMES
=
frozenset
([
'printed'
,])
_MARKER
=
[]
def
checkNameLax
(
self
,
node
,
name
,
allow_magic_methods
=
False
):
def
checkNameLax
(
self
,
node
,
name
=
_MARKER
,
allow_magic_methods
=
False
):
"""Check names if they are allowed.
In ERP5 we are much more lax that than in Zope's original restricted
...
...
@@ -34,14 +39,25 @@ def checkNameLax(self, node, name, allow_magic_methods=False):
if
name
is
None
:
return
if
name
is
_MARKER
:
# we use same implementation for checkName and checkAttrName which access
# the name in different ways ( see RestrictionMutator 3.6.0 )
name
=
node
.
attrname
if
name
.
endswith
(
'__roles__'
):
self
.
error
(
node
,
'"%s" is an invalid variable name because '
'it ends with "__roles__".'
%
name
)
elif
name
in
FORBIDDEN_FUNC_NAMES
:
self
.
error
(
node
,
'"{name}" is a reserved name.'
.
format
(
name
=
name
))
RestrictingNodeTransformer
.
check_name
=
checkNameLax
# XXX we might want to pach visit_Attribute too
try
:
from
RestrictedPython.transformer
import
RestrictingNodeTransformer
RestrictingNodeTransformer
.
check_name
=
checkNameLax
except
ImportError
:
# BBB Restriced 3.6.0
from
RestrictedPython.RestrictionMutator
import
RestrictionMutator
RestrictionMutator
.
checkName
=
RestrictionMutator
.
checkAttrName
=
checkNameLax
from
Acquisition
import
aq_acquire
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment