Changeset - 0619fe53ff6d
[Not reviewed]
default
0 1 0
Mads Kiilerich (mads) - 6 years ago 2020-04-23 22:40:27
mads@kiilerich.com
Grafted from: d95c6556144d
tg: refactor app_cfg blueprint configuration to align more with TG quickstart conventions

Drop prefer_toscawidgets2 and use_toscawidgets - they are not important and
already default to False.
1 file changed with 19 insertions and 40 deletions:
0 comments (0 inline, 0 general)
kallithea/config/app_cfg.py
Show inline comments
 
@@ -47,62 +47,41 @@ from kallithea.model import db
 
log = logging.getLogger(__name__)
 

	
 

	
 
class KallitheaAppConfig(AppConfig):
 
    # Note: AppConfig has a misleading name, as it's not the application
 
    # configuration, but the application configurator. The AppConfig values are
 
    # used as a template to create the actual configuration, which might
 
    # overwrite or extend the one provided by the configurator template.
 

	
 
    # To make it clear, AppConfig creates the config and sets into it the same
 
    # values that AppConfig itself has. Then the values from the config file and
 
    # gearbox options are loaded and merged into the configuration. Then an
 
    # after_init_config(conf) method of AppConfig is called for any change that
 
    # might depend on options provided by configuration files.
 

	
 
    def __init__(self):
 
        super(KallitheaAppConfig, self).__init__()
 
base_config = AppConfig(**{
 
    'package': kallithea,
 

	
 
        self['package'] = kallithea
 

	
 
        self['prefer_toscawidgets2'] = False
 
        self['use_toscawidgets'] = False
 

	
 
        self['renderers'] = []
 

	
 
        # Enable json in expose
 
        self['renderers'].append('json')
 

	
 
        # Configure template rendering
 
        self['renderers'].append('mako')
 
        self['default_renderer'] = 'mako'
 
        self['use_dotted_templatenames'] = False
 
    # Rendering Engines Configuration
 
    'renderers': [
 
        'json',
 
        'mako',
 
    ],
 
    'default_renderer': 'mako',
 
    'use_dotted_templatenames': False,
 

	
 
        # Configure Sessions, store data as JSON to avoid pickle security issues
 
        self['session.enabled'] = True
 
        self['session.data_serializer'] = 'json'
 
    'session.enabled': True,
 
    'session.data_serializer': 'json',
 

	
 
        # Configure the base SQLALchemy Setup
 
        self['use_sqlalchemy'] = True
 
        self['model'] = kallithea.model.base
 
        self['DBSession'] = kallithea.model.meta.Session
 
    'use_sqlalchemy': True,
 
    'model': kallithea.model.base,
 
    'DBSession': kallithea.model.meta.Session,
 

	
 
        # Configure App without an authentication backend.
 
        self['auth_backend'] = None
 
    'auth_backend': None,
 

	
 
        # Use custom error page for these errors. By default, Turbogears2 does not add
 
        # 400 in this list.
 
        # Explicitly listing all is considered more robust than appending to defaults,
 
        # in light of possible future framework changes.
 
        self['errorpage.status_codes'] = [400, 401, 403, 404]
 
    'errorpage.status_codes': [400, 401, 403, 404],
 

	
 
        # Disable transaction manager -- currently Kallithea takes care of transactions itself
 
        self['tm.enabled'] = False
 
    'tm.enabled': False,
 

	
 
        # Set the default i18n source language so TG doesn't search beyond 'en' in Accept-Language.
 
        self['i18n.lang'] = 'en'
 

	
 

	
 
base_config = KallitheaAppConfig()
 
    'i18n.lang': 'en',
 
})
 

	
 
# DebugBar, a debug toolbar for TurboGears2.
 
# (https://github.com/TurboGears/tgext.debugbar)
0 comments (0 inline, 0 general)