commit | author | age
|
6c9959
|
1 |
from pyramid.config import Configurator |
b25335
|
2 |
from pyramid_zodbconn import get_connection |
CM |
3 |
|
19b820
|
4 |
from pyramid.authentication import AuthTktAuthenticationPolicy |
6c9959
|
5 |
from pyramid.authorization import ACLAuthorizationPolicy |
CM |
6 |
|
fa9113
|
7 |
from .models import appmaker |
K |
8 |
from .security import groupfinder |
b25335
|
9 |
|
CM |
10 |
def root_factory(request): |
|
11 |
conn = get_connection(request) |
|
12 |
return appmaker(conn.root()) |
6c9959
|
13 |
|
6d1eee
|
14 |
|
6c9959
|
15 |
def main(global_config, **settings): |
6d1eee
|
16 |
""" This function returns a Pyramid WSGI application. |
6c9959
|
17 |
""" |
19b820
|
18 |
authn_policy = AuthTktAuthenticationPolicy( |
MM |
19 |
'sosecret', callback=groupfinder, hashalg='sha512') |
6c9959
|
20 |
authz_policy = ACLAuthorizationPolicy() |
9619d0
|
21 |
config = Configurator(root_factory=root_factory, settings=settings) |
85623b
|
22 |
settings = config.get_settings() |
SP |
23 |
settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager' |
9619d0
|
24 |
config.set_authentication_policy(authn_policy) |
CM |
25 |
config.set_authorization_policy(authz_policy) |
63dcf9
|
26 |
config.include('pyramid_chameleon') |
d5f734
|
27 |
config.include('pyramid_tm') |
85623b
|
28 |
config.include('pyramid_retry') |
d5f734
|
29 |
config.include('pyramid_zodbconn') |
4466bb
|
30 |
config.add_static_view('static', 'static', cache_max_age=3600) |
19d1eb
|
31 |
config.scan() |
6c9959
|
32 |
return config.make_wsgi_app() |