vigiboard / vigiboard / config / app_cfg.py @ d3c47597
History | View | Annotate | Download (2.71 KB)
1 |
# -*- coding: utf-8 -*-
|
---|---|
2 |
# vim: set fileencoding=utf-8 sw=4 ts=4 et :
|
3 |
"""
|
4 |
Global configuration file for TG2-specific settings in vigiboard.
|
5 |
|
6 |
This file complements development/deployment.ini.
|
7 |
|
8 |
Please note that **all the argument values are strings**. If you want to
|
9 |
convert them into boolean, for example, you should use the
|
10 |
:func:`paste.deploy.converters.asbool` function, as in::
|
11 |
|
12 |
from paste.deploy.converters import asbool
|
13 |
setting = asbool(global_conf.get('the_setting'))
|
14 |
|
15 |
"""
|
16 |
|
17 |
from tg.configuration import AppConfig |
18 |
|
19 |
class MyAppConfig(AppConfig): |
20 |
"""We overload AppConfig to prevent it from loading init_model()"""
|
21 |
|
22 |
def __init__(self): |
23 |
AppConfig.__init__(self)
|
24 |
|
25 |
def setup_sqlalchemy(self): |
26 |
"""
|
27 |
TG2 needs to configure the DB session before anything else, then it
|
28 |
calls init_model(). In our case, the DB session is already configured
|
29 |
so the function call is unnecessary. We suppress TG2's behaviour here.
|
30 |
"""
|
31 |
pass
|
32 |
|
33 |
import vigiboard |
34 |
from vigiboard import model |
35 |
from vigiboard.lib import app_globals, helpers |
36 |
|
37 |
base_config = MyAppConfig() |
38 |
base_config.renderers = [] |
39 |
|
40 |
base_config.package = vigiboard |
41 |
|
42 |
#Set the default renderer
|
43 |
base_config.default_renderer = 'genshi'
|
44 |
base_config.renderers.append('genshi')
|
45 |
# if you want raw speed and have installed chameleon.genshi
|
46 |
# you should try to use this renderer instead.
|
47 |
# warning: for the moment chameleon does not handle i18n translations
|
48 |
#base_config.renderers.append('chameleon_genshi')
|
49 |
|
50 |
#Configure the base SQLALchemy Setup
|
51 |
base_config.use_sqlalchemy = True
|
52 |
base_config.model = model |
53 |
base_config.DBSession = model.DBSession |
54 |
|
55 |
# Configure the authentication backend
|
56 |
base_config.auth_backend = 'sqlalchemy'
|
57 |
base_config.sa_auth.dbsession = model.DBSession |
58 |
# what is the class you want to use to search for users in the database
|
59 |
base_config.sa_auth.user_class = model.User |
60 |
# what is the class you want to use to search for groups in the database
|
61 |
base_config.sa_auth.group_class = model.UserGroup |
62 |
# what is the class you want to use to search for permissions in the database
|
63 |
base_config.sa_auth.permission_class = model.Permission |
64 |
# The name "groups" is already used for groups of hosts.
|
65 |
# We use "usergroups" when referering to users to avoid confusion.
|
66 |
base_config.sa_auth.translations.groups = 'usergroups'
|
67 |
|
68 |
# override this if you would like to provide a different who plugin for
|
69 |
# managing login and logout of your application
|
70 |
base_config.sa_auth.form_plugin = None
|
71 |
|
72 |
# You may optionally define a page where you want users to be redirected to
|
73 |
# on login:
|
74 |
base_config.sa_auth.post_login_url = '/post_login'
|
75 |
|
76 |
# You may optionally define a page where you want users to be redirected to
|
77 |
# on logout:
|
78 |
base_config.sa_auth.post_logout_url = '/post_logout'
|
79 |
|