Feature: Take some of the parameters from the Environment so that it can work in a containerized environment
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
import datetime
|
||||
import os
|
||||
from pyramid.config import Configurator
|
||||
from sqlalchemy import engine_from_config
|
||||
from sqlalchemy.engine.url import make_url
|
||||
|
||||
from pyramid.authentication import AuthTktAuthenticationPolicy
|
||||
from pyramid.authorization import ACLAuthorizationPolicy
|
||||
@ -10,16 +12,23 @@ from brewman.models import initialize_sql
|
||||
from brewman.renderers import json_renderer, CSVRenderer
|
||||
from brewman.security import groupfinder
|
||||
|
||||
current_table = 1
|
||||
|
||||
|
||||
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
|
||||
engine = engine_from_config(settings, 'sqlalchemy.')
|
||||
initialize_sql(engine)
|
||||
|
||||
session_factory = SignedCookieSessionFactory('secret')
|
||||
SECRET_KEY = os.environ.get('SECRET_KEY', settings.get('secret_key', ''))
|
||||
session_factory = SignedCookieSessionFactory(SECRET_KEY)
|
||||
|
||||
authentication_policy = AuthTktAuthenticationPolicy('brewman', timeout=900, reissue_time=90, callback=groupfinder)
|
||||
authorization_policy = ACLAuthorizationPolicy()
|
||||
|
||||
Reference in New Issue
Block a user