File: __init__.py

package info (click to toggle)
python-pyramid 1.10.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,044 kB
  • sloc: python: 43,041; makefile: 28
file content (32 lines) | stat: -rw-r--r-- 915 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class RootFactory(object):
    __acl__ = [('Allow', 'fred', 'view')]

    def __init__(self, request):
        pass


class LocalRootFactory(object):
    __acl__ = [('Allow', 'bob', 'view')]

    def __init__(self, request):
        pass


def includeme(config):
    from pyramid.authentication import RemoteUserAuthenticationPolicy
    from pyramid.authorization import ACLAuthorizationPolicy

    authn_policy = RemoteUserAuthenticationPolicy()
    authz_policy = ACLAuthorizationPolicy()
    config._set_authentication_policy(authn_policy)
    config._set_authorization_policy(authz_policy)
    config.add_static_view('allowed', 'tests:fixtures/static/')
    config.add_static_view(
        'protected', 'tests:fixtures/static/', permission='view'
    )
    config.add_static_view(
        'factory_protected',
        'tests:fixtures/static/',
        permission='view',
        factory=LocalRootFactory,
    )