commit | author | age
|
a7fe30
|
1 |
from pyramid.view import forbidden_view_config, view_config |
CM |
2 |
from pyramid.response import Response |
|
3 |
from pyramid.authentication import AuthTktAuthenticationPolicy |
|
4 |
from pyramid.authorization import ACLAuthorizationPolicy |
|
5 |
|
|
6 |
@forbidden_view_config(route_name='foo') |
|
7 |
def foo_forbidden(request): # pragma: no cover |
|
8 |
return Response('foo_forbidden') |
|
9 |
|
|
10 |
@forbidden_view_config() |
|
11 |
def forbidden(request): |
|
12 |
return Response('generic_forbidden') |
|
13 |
|
|
14 |
@view_config(route_name='foo') |
|
15 |
def foo(request): # pragma: no cover |
|
16 |
return Response('OK foo') |
|
17 |
|
|
18 |
@view_config(route_name='bar') |
|
19 |
def bar(request): # pragma: no cover |
|
20 |
return Response('OK bar') |
|
21 |
|
|
22 |
def includeme(config): |
4bc4b4
|
23 |
authn_policy = AuthTktAuthenticationPolicy('seekri1', hashalg='sha512') |
a7fe30
|
24 |
authz_policy = ACLAuthorizationPolicy() |
CM |
25 |
config.set_authentication_policy(authn_policy) |
|
26 |
config.set_authorization_policy(authz_policy) |
|
27 |
config.set_default_permission('a') |
|
28 |
config.add_route('foo', '/foo') |
|
29 |
config.add_route('bar', '/bar') |
dd3cc8
|
30 |
config.scan('tests.pkgs.forbiddenview') |
a7fe30
|
31 |
|