Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

vigigraph / vigigraph / websetup.py @ 56b77667

History | View | Annotate | Download (1.35 KB)

1
# -*- coding: utf-8 -*-
2
# Copyright (C) 2011-2020 CS-SI
3
# License: GNU GPL v2 <http://www.gnu.org/licenses/gpl-2.0.html>
4

    
5
"""Setup the vigigraph application"""
6

    
7
# pylint: disable-msg=W0613
8
# W0613: Unused argument
9

    
10
import imp
11

    
12
__all__ = ['setup_app', 'populate_db']
13

    
14
def setup_app(command, conf, variables):
15
    """Place any commands to setup vigigraph here"""
16
    from vigilo.turbogears import populate_db as tg_pop_db
17

    
18
    # Charge le fichier "app_cfg.py" se trouvant aux côtés de "settings.ini".
19
    mod_info = imp.find_module('app_cfg', [ conf.global_conf['here'] ])
20
    app_cfg = imp.load_module('vigigraph.config.app_cfg', *mod_info)
21

    
22
    # Initialisation de l'environnement d'exécution.
23
    load_environment = app_cfg.base_config.make_load_environment()
24
    load_environment(conf.global_conf, conf.local_conf)
25
    tg_pop_db()
26

    
27
def populate_db(bind):
28
    from vigilo.models.session import DBSession
29
    from vigilo.models import tables
30

    
31
    permissions = {
32
        'vigigraph-access':
33
            'Gives access to VigiGraph',
34
    }
35

    
36
    for (permission_name, description) in permissions.iteritems():
37
        if not tables.Permission.by_permission_name(unicode(permission_name)):
38
            DBSession.add(tables.Permission(
39
                permission_name=unicode(permission_name),
40
                description=unicode(description),
41
            ))
42
    DBSession.flush()