Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

vigiboard / vigiboard / config / middleware.py @ e6029893

History | View | Annotate | Download (1.96 KB)

1 d3c47597 Francois POIROTTE
# -*- coding: utf-8 -*-
2 2e5394d8 Gabriel DE PERTHUIS
# vim: set fileencoding=utf-8 sw=4 ts=4 et :
3 57f7cb3f Gabriel DE PERTHUIS
"""WSGI middleware initialization for the vigiboard application."""
4 d3c47597 Francois POIROTTE
5
from vigiboard.config.app_cfg import base_config
6
from vigiboard.config.environment import load_environment
7 57f7cb3f Gabriel DE PERTHUIS
8 5f2cd70a Francois POIROTTE
from pkg_resources import resource_filename
9
from paste.cascade import Cascade
10
from paste.urlparser import StaticURLParser
11
12 57f7cb3f Gabriel DE PERTHUIS
__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 0f56fff9 Francois POIROTTE
    C{app_conf} contains all the application-specific settings (those defined
27
    under ``[app:main]``).
28 57f7cb3f Gabriel DE PERTHUIS
    
29 0f56fff9 Francois POIROTTE
    @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 57f7cb3f Gabriel DE PERTHUIS
    """
37 5f2cd70a Francois POIROTTE
    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 08d86103 Francois POIROTTE
    local_static = StaticURLParser(resource_filename(
48
                'vigiboard', 'public'))
49
    app = Cascade([app_static, common_static, local_static, app])
50 0f56fff9 Francois POIROTTE
51 57f7cb3f Gabriel DE PERTHUIS
    return app