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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tristan Cavelier
erp5
Commits
935a2cfc
Commit
935a2cfc
authored
Apr 02, 2015
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename unrestricted_contextmanager to super_user and use it directly in UnrestrictedMethod
parent
15f7d8f1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
product/ERP5Type/UnrestrictedMethod.py
product/ERP5Type/UnrestrictedMethod.py
+8
-5
No files found.
product/ERP5Type/UnrestrictedMethod.py
View file @
935a2cfc
...
...
@@ -65,7 +65,10 @@ def UnrestrictedMethod(function):
This method is dangerous. Enough said. Be careful.
"""
return
lambda
*
args
,
**
kw
:
unrestricted_apply
(
function
,
args
,
kw
)
def
unrestricted_apply
(
*
args
,
**
kw
):
with
super_user
():
return
function
(
*
args
,
**
kw
)
return
unrestricted_apply
def
unrestricted_apply
(
function
,
args
=
(),
kw
=
{}):
# XXX-JPS: naming
"""Function to bypass all security checks
...
...
@@ -74,12 +77,12 @@ def unrestricted_apply(function, args=(), kw={}): # XXX-JPS: naming
docstring for more information. Never use this, until you are 100% certain
that you have no other way.
"""
with
unrestricted_contextmanag
er
():
return
apply
(
function
,
args
,
kw
)
with
super_us
er
():
return
function
(
*
args
,
**
kw
)
@
contextmanager
def
unrestricted_contextmanag
er
():
"""
Function
to bypass all security checks
def
super_us
er
():
"""
Context manager
to bypass all security checks
This function is as dangerous as 'UnrestrictedMethod' decorator. Read its
docstring for more information. Never use this, until you are 100% certain
...
...
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