~maddevelopers/mg5amcnlo/WWW5_caching

« back to all changes in this revision

Viewing changes to madgraph3/config/app_cfg.py

  • Committer: John Doe
  • Date: 2013-03-25 20:27:02 UTC
  • Revision ID: john.doe@gmail.com-20130325202702-5sk3t1r8h33ca4p4
first clean version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
"""
 
3
Global configuration file for TG2-specific settings in madgraph3.
 
4
 
 
5
This file complements development/deployment.ini.
 
6
 
 
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::
 
10
    
 
11
    from paste.deploy.converters import asbool
 
12
    setting = asbool(global_conf.get('the_setting'))
 
13
 
 
14
"""
 
15
 
 
16
from tg.configuration import AppConfig
 
17
 
 
18
import madgraph3
 
19
from madgraph3 import model
 
20
from madgraph3.lib import app_globals, helpers 
 
21
 
 
22
base_config = AppConfig()
 
23
base_config.renderers = []
 
24
base_config.prefer_toscawidgets2 = True
 
25
 
 
26
base_config.package = madgraph3
 
27
 
 
28
#Enable json in expose
 
29
base_config.renderers.append('json')
 
30
 
 
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')
 
34
 
 
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
 
46
 
 
47
# YOU MUST CHANGE THIS VALUE IN PRODUCTION TO SECURE YOUR APP 
 
48
base_config.sa_auth.cookie_secret = "ChangeME" 
 
49
 
 
50
base_config.auth_backend = 'sqlalchemy'
 
51
 
 
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
 
54
 
 
55
from tg.configuration.auth import TGAuthMetadata
 
56
 
 
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]
 
67
 
 
68
base_config.sa_auth.dbsession = model.DBSession
 
69
 
 
70
base_config.sa_auth.authmetadata = ApplicationAuthMetadata(base_config.sa_auth)
 
71
 
 
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()]
 
75
 
 
76
# You can add more repoze.who metadata providers to fetch
 
77
# user metadata.
 
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()]
 
81
 
 
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
 
85
 
 
86
# override this if you are using a different charset for the login form
 
87
base_config.sa_auth.charset = 'utf-8'
 
88
 
 
89
# You may optionally define a page where you want users to be redirected to
 
90
# on login:
 
91
base_config.sa_auth.post_login_url = '/post_login'
 
92
 
 
93
# You may optionally define a page where you want users to be redirected to
 
94
# on logout:
 
95
base_config.sa_auth.post_logout_url = '/post_logout'