|
1
|
|
|
import os |
|
2
|
|
|
|
|
3
|
|
|
from pyramid.config import Configurator |
|
4
|
|
|
from pyramid.settings import aslist |
|
5
|
|
|
|
|
6
|
|
|
from atramhasis.renderers import json_renderer_verbose |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
def includeme(config): |
|
10
|
|
|
"""this function adds some configuration for the application""" |
|
11
|
|
|
config.include('pyramid_jinja2') |
|
12
|
|
|
config.include('pyramid_tm') |
|
13
|
|
|
config.add_static_view('static', 'static', cache_max_age=3600) |
|
14
|
|
|
config.add_renderer('csv', 'atramhasis.renderers.CSVRenderer') |
|
15
|
|
|
config.add_renderer('skosrenderer_verbose', json_renderer_verbose) |
|
16
|
|
|
# Rewrite urls with trailing slash |
|
17
|
|
|
config.include('pyramid_rewrite') |
|
18
|
|
|
config.include("pyramid_openapi3") |
|
19
|
|
|
config.include('atramhasis.routes') |
|
20
|
|
|
config.include('pyramid_skosprovider') |
|
21
|
|
|
config.include('atramhasis.cache') |
|
22
|
|
|
config.scan('pyramid_skosprovider') |
|
23
|
|
|
|
|
24
|
|
|
config.scan() |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
def main(global_config, **settings): |
|
28
|
|
|
""" This function returns a Pyramid WSGI application. |
|
29
|
|
|
""" |
|
30
|
|
|
settings['layout.focus_conceptschemes'] = aslist(settings['layout.focus_conceptschemes'], flatten=False) |
|
31
|
|
|
|
|
32
|
|
|
dump_location = settings['atramhasis.dump_location'] |
|
33
|
|
|
if not os.path.exists(dump_location): |
|
34
|
|
|
os.makedirs(dump_location) |
|
35
|
|
|
|
|
36
|
|
|
config = Configurator(settings=settings) |
|
37
|
|
|
|
|
38
|
|
|
return load_app(config, settings) |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
def load_app(config, settings): |
|
42
|
|
|
from pyramid.session import SignedCookieSessionFactory |
|
43
|
|
|
atramhasis_session_factory = SignedCookieSessionFactory(settings['atramhasis.session_factory.secret']) |
|
44
|
|
|
config.set_session_factory(atramhasis_session_factory) |
|
45
|
|
|
|
|
46
|
|
|
includeme(config) |
|
47
|
|
|
|
|
48
|
|
|
config.add_translation_dirs('atramhasis:locale/') |
|
49
|
|
|
|
|
50
|
|
|
config.include('atramhasis.data:db') |
|
51
|
|
|
|
|
52
|
|
|
return config.make_wsgi_app() |
|
53
|
|
|
|