vigiboard / vigiboard / config / middleware.py @ 5f2cd70a
History | View | Annotate | Download (1.86 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 |
|
8 |
from pkg_resources import resource_filename |
9 |
from paste.cascade import Cascade |
10 |
from paste.urlparser import StaticURLParser |
11 |
|
12 |
__all__ = ['make_app']
|
13 |
|
14 |
# Use base_config to setup the necessary PasteDeploy application factory.
|
15 |
# make_base_app will wrap the TG2 app with all the middleware it needs.
|
16 |
make_base_app = base_config.setup_tg_wsgi_app(load_environment) |
17 |
|
18 |
|
19 |
def make_app(global_conf, full_stack=True, **app_conf): |
20 |
"""
|
21 |
Set vigiboard up with the settings found in the PasteDeploy configuration
|
22 |
file used.
|
23 |
|
24 |
This is the PasteDeploy factory for the vigiboard application.
|
25 |
|
26 |
C{app_conf} contains all the application-specific settings (those defined
|
27 |
under ``[app:main]``).
|
28 |
|
29 |
@param global_conf: The global settings for vigiboard (those
|
30 |
defined under the ``[DEFAULT]`` section).
|
31 |
@type global_conf: C{dict}
|
32 |
@param full_stack: Should the whole TG2 stack be set up?
|
33 |
@type full_stack: C{str} or C{bool}
|
34 |
@return: The vigiboard application with all the relevant middleware
|
35 |
loaded.
|
36 |
"""
|
37 |
app = make_base_app(global_conf, full_stack=full_stack, **app_conf) |
38 |
|
39 |
# On définit 2 middlewares pour fichiers statiques qui cherchent
|
40 |
# les fichiers dans le thème actuellement chargé.
|
41 |
# Le premier va les chercher dans le dossier des fichiers spécifiques
|
42 |
# à l'application, le second cherche dans les fichiers communs.
|
43 |
app_static = StaticURLParser(resource_filename( |
44 |
'vigilo.themes.public', 'vigiboard')) |
45 |
common_static = StaticURLParser(resource_filename( |
46 |
'vigilo.themes.public', 'common')) |
47 |
app = Cascade([app_static, common_static, app]) |
48 |
|
49 |
return app
|
50 |
|