Commit 00498748 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

moved redis initialization, so other modules can access it

parent 3e9292d9
Pipeline #1684 passed with stage
in 1 minute and 18 seconds
......@@ -6,19 +6,25 @@ Modules in this package:
import logging
from flask import Flask
from redis import StrictRedis
from fractalis.session import RedisSessionInterface
from fractalis.analytics.controller import analytics_blueprint
app = Flask(__name__)
# Configure app
app.config.from_object('fractalis.config')
try:
app.config.from_envvar('FRACTALIS_CONFIG')
except RuntimeError:
app.logger.warning("FRACTALIS_CONFIG is not set. Using defaults.")
app.session_interface = RedisSessionInterface(app.config)
redis = StrictRedis(host=app.config['REDIS_HOST'],
port=app.config['REDIS_PORT'])
app.session_interface = RedisSessionInterface(redis)
app.register_blueprint(analytics_blueprint, url_prefix='/analytics')
if __name__ == '__main__':
......
from uuid import uuid4
from redis import StrictRedis
from flask.sessions import SecureCookieSessionInterface, SecureCookieSession
......@@ -22,9 +21,8 @@ class RedisSessionInterface(SecureCookieSessionInterface):
sid (UUID) -- A session id
"""
def __init__(self, app_config):
self.redis = StrictRedis(host=app_config['REDIS_HOST'],
port=app_config['REDIS_PORT'])
def __init__(self, redis):
self.redis = redis
def open_session(self, app, request):
sid = request.cookies.get(app.session_cookie_name)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment