Let any 'admin' user elevate to 'root' for full system access

But otherwise, let the Administrator role be "normal" and have perms of
its own.  Hopefully cuts down on unwanted screen noise for admins.
This commit is contained in:
Lance Edgar 2016-10-18 16:59:38 -05:00
parent 4599eaad97
commit 6bf60365ba
6 changed files with 102 additions and 48 deletions

View file

@ -106,11 +106,22 @@ def provide_postgresql_settings(settings):
settings.setdefault('tm.attempts', 2)
class Root(dict):
"""
Root factory for Pyramid. This is necessary to make the current request
available to the authorization policy object, which needs it to check if
the current request "is root".
"""
def __init__(self, request):
self.request = request
def make_pyramid_config(settings):
"""
Make a Pyramid config object from the given settings.
"""
config = Configurator(settings=settings)
config = Configurator(settings=settings, root_factory=Root)
# Configure user authentication / authorization.
config.set_authentication_policy(SessionAuthenticationPolicy())