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):
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_contextmanager():
return apply(function, args, kw)
with super_user():
return function(*args, **kw)
@contextmanager
def unrestricted_contextmanager():
"""Function to bypass all security checks
def super_user():
"""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
......
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