Skip to content

Instantly share code, notes, and snippets.

@mekarpeles
Created November 16, 2012 09:23
Show Gist options
  • Save mekarpeles/4085832 to your computer and use it in GitHub Desktop.
Save mekarpeles/4085832 to your computer and use it in GitHub Desktop.
Sessions and authentication module for Waltz
#-*- coding: utf-8 -*-
"""
auth.py
~~~~~~~
Sessions and authentication
"""
def initialize_session(web, app, storage_method, **kwargs):
web.config.session_parameters['ignore_expiry'] = False
def default_session(web_session):
default_session = {'logged': False,
'username': '',
}
web_session.update(default_session)
session = web.session.Session(app, storage_method, initializer=default_session)
def session_hook():
"""Expose variables to subapps"""
web.ctx.session = {session}
session_hook = kwargs.setdefault('hook', session_hook)
app.add_processor(web.loadhook(session_hook))
return session
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment