source: OpenWorkouts-current/ow/__init__.py @ 5ec3a0b

currentfeature/docs
Last change on this file since 5ec3a0b was 5ec3a0b, checked in by borja <borja@…>, 5 years ago

Imported sources from the old python2-only repository:

  • Modified the code so it is python 3.6 compatible
  • Fixed deprecation warnings, pyramid 1.10.x supported now
  • Fixed deprecation warnings about some libraries, like pyramid-simpleform
  • Added pytest-pycodestyle and pytest-flakes for automatic checks on the source code files when running tests.
  • Added default pytest.ini setup to enforce some default parameters when running tests.
  • Cleaned up the code a bit, catched up with tests coverage.
  • Property mode set to 100644
File size: 1.5 KB
Line 
1from pyramid.config import Configurator
2from pyramid_zodbconn import get_connection
3from pyramid.authentication import AuthTktAuthenticationPolicy
4from pyramid.authorization import ACLAuthorizationPolicy
5from pyramid.session import SignedCookieSessionFactory
6
7from .models import appmaker
8from .security import groupfinder
9
10
11def root_factory(request):  # pragma: no cover
12    conn = get_connection(request)
13    return appmaker(conn.root())
14
15
16def main(global_config, **settings):  # pragma: no cover
17    """
18    This function returns a Pyramid WSGI application.
19    """
20    session_factory = SignedCookieSessionFactory(
21        'V4j:DL12^Gs//ho5)V94$j"Ue"F%wn{BT]KrSx`b3pmRj<Z&e3QP|fgPGEZT@#',
22        cookie_name='ow-session')
23
24    authn_policy = AuthTktAuthenticationPolicy(
25        'l9|^@~wQoVKPQoI`GHK5M9ps@S7L:QNU?pF}.jI(9RWZVc<EM)aQv/j~l#xC++;5',
26        callback=groupfinder,
27        hashalg='sha512')
28
29    authz_policy = ACLAuthorizationPolicy()
30
31    config = Configurator(root_factory=root_factory, settings=settings)
32    config.set_authentication_policy(authn_policy)
33    config.set_authorization_policy(authz_policy)
34    config.set_session_factory(session_factory)
35    config.include('pyramid_chameleon')
36    config.include('pyramid_tm')
37    config.include('pyramid_retry')
38    config.include('pyramid_zodbconn')
39    config.add_static_view('static', 'static', cache_max_age=3600)
40    config.add_translation_dirs(
41        'ow:locale',
42        'formencode:i18n')
43    config.scan()
44    return config.make_wsgi_app()
Note: See TracBrowser for help on using the repository browser.