Commit 935a2cfc authored by Julien Muchembled's avatar Julien Muchembled

Rename unrestricted_contextmanager to super_user and use it directly in UnrestrictedMethod

parent 15f7d8f1
...@@ -65,7 +65,10 @@ def UnrestrictedMethod(function): ...@@ -65,7 +65,10 @@ def UnrestrictedMethod(function):
This method is dangerous. Enough said. Be careful. 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 def unrestricted_apply(function, args=(), kw={}): # XXX-JPS: naming
"""Function to bypass all security checks """Function to bypass all security checks
...@@ -74,12 +77,12 @@ def unrestricted_apply(function, args=(), kw={}): # XXX-JPS: naming ...@@ -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 docstring for more information. Never use this, until you are 100% certain
that you have no other way. that you have no other way.
""" """
with unrestricted_contextmanager(): with super_user():
return apply(function, args, kw) return function(*args, **kw)
@contextmanager @contextmanager
def unrestricted_contextmanager(): def super_user():
"""Function to bypass all security checks """Context manager to bypass all security checks
This function is as dangerous as 'UnrestrictedMethod' decorator. Read its This function is as dangerous as 'UnrestrictedMethod' decorator. Read its
docstring for more information. Never use this, until you are 100% certain docstring for more information. Never use this, until you are 100% certain
......
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