vigiboard / vigiboard / config / middleware.py @ d3c47597
History | View | Annotate | Download (1.76 KB)
1 |
# -*- coding: utf-8 -*-
|
---|---|
2 |
# vim: set fileencoding=utf-8 sw=4 ts=4 et :
|
3 |
"""WSGI middleware initialization for the vigiboard application."""
|
4 |
|
5 |
from vigiboard.config.app_cfg import base_config |
6 |
from vigiboard.config.environment import load_environment |
7 |
from vigiboard.config.vigiboard_cfg import vigiboard_config |
8 |
from paste.cascade import Cascade |
9 |
from paste.urlparser import StaticURLParser |
10 |
|
11 |
__all__ = ['make_app']
|
12 |
|
13 |
# Use base_config to setup the necessary PasteDeploy application factory.
|
14 |
# make_base_app will wrap the TG2 app with all the middleware it needs.
|
15 |
make_base_app = base_config.setup_tg_wsgi_app(load_environment) |
16 |
|
17 |
|
18 |
def make_app(global_conf, full_stack=True, **app_conf): |
19 |
"""
|
20 |
Set vigiboard up with the settings found in the PasteDeploy configuration
|
21 |
file used.
|
22 |
|
23 |
:param global_conf: The global settings for vigiboard (those
|
24 |
defined under the ``[DEFAULT]`` section).
|
25 |
:type global_conf: dict
|
26 |
:param full_stack: Should the whole TG2 stack be set up?
|
27 |
:type full_stack: str or bool
|
28 |
:return: The vigiboard application with all the relevant middleware
|
29 |
loaded.
|
30 |
|
31 |
This is the PasteDeploy factory for the vigiboard application.
|
32 |
|
33 |
``app_conf`` contains all the application-specific settings (those defined
|
34 |
under ``[app:main]``.
|
35 |
|
36 |
|
37 |
"""
|
38 |
# chargement de la config
|
39 |
for i in vigiboard_config: |
40 |
app_conf[i] = vigiboard_config[i] |
41 |
|
42 |
# on cré l'application de base
|
43 |
app = make_base_app(global_conf, full_stack=True, **app_conf)
|
44 |
|
45 |
# on rajoute le path public de l'application
|
46 |
import vigiboard |
47 |
app = Cascade([ |
48 |
StaticURLParser(global_conf['here'] + '/' + app_conf['appname'] + '/public'), |
49 |
StaticURLParser(vigiboard.__file__.rsplit('/',1)[0] + '/public'),app] |
50 |
) |
51 |
|
52 |
return app
|
53 |
|