Michael Merickel
2018-10-15 0c29cf2df41600d3906d521c72991c7686018b71
commit | author | age
0b2629 1 class RootFactory(object):
CM 2     __acl__ = [('Allow', 'fred', 'view')]
0c29cf 3
0b2629 4     def __init__(self, request):
CM 5         pass
0c29cf 6
0b2629 7
CM 8 class LocalRootFactory(object):
9     __acl__ = [('Allow', 'bob', 'view')]
0c29cf 10
0b2629 11     def __init__(self, request):
CM 12         pass
0c29cf 13
0b2629 14
CM 15 def includeme(config):
0c29cf 16     from pyramid.authentication import RemoteUserAuthenticationPolicy
MM 17     from pyramid.authorization import ACLAuthorizationPolicy
18
19     authn_policy = RemoteUserAuthenticationPolicy()
20     authz_policy = ACLAuthorizationPolicy()
21     config._set_authentication_policy(authn_policy)
22     config._set_authorization_policy(authz_policy)
23     config.add_static_view('allowed', 'tests:fixtures/static/')
24     config.add_static_view(
25         'protected', 'tests:fixtures/static/', permission='view'
26     )
27     config.add_static_view(
28         'factory_protected',
29         'tests:fixtures/static/',
30         permission='view',
31         factory=LocalRootFactory,
32     )