be8f71259c
Version: Bumped to 4.0 Added: Dependency of pyramid_tm Changed: Changed from ACL Authorization to custom Permission Authorization Policy Using more of inbuilt functions. This should reduce the number of DB hits and improve performance
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
import os
|
|
from pyramid.config import Configurator
|
|
|
|
from pyramid.session import SignedCookieSessionFactory
|
|
from brewman.renderers import json_renderer, CSVRenderer
|
|
from brewman.transactional_view_deriver import transactional_view
|
|
|
|
|
|
def main(global_config, **settings):
|
|
""" This function returns a Pyramid WSGI application.
|
|
"""
|
|
if 'sqlalchemy.url' not in settings:
|
|
DB_NAME = os.environ['DB_NAME']
|
|
DB_USER = os.environ['DB_USER']
|
|
DB_PASS = os.environ['DB_PASS']
|
|
DB_URI = 'postgresql://{0}:{1}@postgres:5432/{2}'.format(
|
|
DB_USER, DB_PASS, DB_NAME
|
|
)
|
|
settings['sqlalchemy.url']= DB_URI
|
|
|
|
SECRET_KEY = os.environ.get('SECRET_KEY', settings.get('secret_key', ''))
|
|
session_factory = SignedCookieSessionFactory(SECRET_KEY)
|
|
|
|
|
|
config = Configurator(
|
|
settings=settings,
|
|
session_factory=session_factory
|
|
)
|
|
config.include('.security')
|
|
config.include('.models')
|
|
config.include('.routes')
|
|
config.add_view_deriver(transactional_view)
|
|
config.add_renderer(name='json', factory=json_renderer)
|
|
config.add_renderer(name='csv', factory=CSVRenderer)
|
|
config.scan()
|
|
|
|
return config.make_wsgi_app()
|
|
|