Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

vigiboard / vigiboard / config / middleware.py @ 9ac8bfb5

History | View | Annotate | Download (1.7 KB)

1
# vim: set fileencoding=utf-8 sw=4 ts=4 et :
2
from __future__ import absolute_import
3

    
4
"""WSGI middleware initialization for the vigiboard application."""
5
from .app_cfg import base_config
6
from .environment import load_environment
7
from .vigiboard_conf 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

    
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