1
# -*- coding: utf-8 -*-
3
Global configuration file for TG2-specific settings in madgraph3.
5
This file complements development/deployment.ini.
7
Please note that **all the argument values are strings**. If you want to
8
convert them into boolean, for example, you should use the
9
:func:`paste.deploy.converters.asbool` function, as in::
11
from paste.deploy.converters import asbool
12
setting = asbool(global_conf.get('the_setting'))
16
from tg.configuration import AppConfig
19
from madgraph3 import model
20
from madgraph3.lib import app_globals, helpers
22
base_config = AppConfig()
23
base_config.renderers = []
24
base_config.prefer_toscawidgets2 = True
26
base_config.package = madgraph3
28
#Enable json in expose
29
base_config.renderers.append('json')
31
#Enable genshi in expose to have a lingua franca for extensions and pluggable apps
32
#you can remove this if you don't plan to use it.
33
base_config.renderers.append('genshi')
35
#Set the default renderer
36
base_config.default_renderer = 'genshi'
37
# if you want raw speed and have installed chameleon.genshi
38
# you should try to use this renderer instead.
39
# warning: for the moment chameleon does not handle i18n translations
40
#base_config.renderers.append('chameleon_genshi')
41
#Configure the base SQLALchemy Setup
42
base_config.use_sqlalchemy = True
43
base_config.model = madgraph3.model
44
base_config.DBSession = madgraph3.model.DBSession
45
# Configure the authentication backend
47
# YOU MUST CHANGE THIS VALUE IN PRODUCTION TO SECURE YOUR APP
48
base_config.sa_auth.cookie_secret = "ChangeME"
50
base_config.auth_backend = 'sqlalchemy'
52
# what is the class you want to use to search for users in the database
53
base_config.sa_auth.user_class = model.User
55
from tg.configuration.auth import TGAuthMetadata
57
#This tells to TurboGears how to retrieve the data for your user
58
class ApplicationAuthMetadata(TGAuthMetadata):
59
def __init__(self, sa_auth):
60
self.sa_auth = sa_auth
61
def get_user(self, identity, userid):
62
return self.sa_auth.dbsession.query(self.sa_auth.user_class).filter_by(user_name=userid).first()
63
def get_groups(self, identity, userid):
64
return [g.group_name for g in identity['user'].groups]
65
def get_permissions(self, identity, userid):
66
return [p.permission_name for p in identity['user'].permissions]
68
base_config.sa_auth.dbsession = model.DBSession
70
base_config.sa_auth.authmetadata = ApplicationAuthMetadata(base_config.sa_auth)
72
# You can use a different repoze.who Authenticator if you want to
73
# change the way users can login
74
#base_config.sa_auth.authenticators = [('myauth', SomeAuthenticator()]
76
# You can add more repoze.who metadata providers to fetch
78
# Remember to set base_config.sa_auth.authmetadata to None
79
# to disable authmetadata and use only your own metadata providers
80
#base_config.sa_auth.mdproviders = [('myprovider', SomeMDProvider()]
82
# override this if you would like to provide a different who plugin for
83
# managing login and logout of your application
84
base_config.sa_auth.form_plugin = None
86
# override this if you are using a different charset for the login form
87
base_config.sa_auth.charset = 'utf-8'
89
# You may optionally define a page where you want users to be redirected to
91
base_config.sa_auth.post_login_url = '/post_login'
93
# You may optionally define a page where you want users to be redirected to
95
base_config.sa_auth.post_logout_url = '/post_logout'