Skip to content

Instantly share code, notes, and snippets.

Created December 18, 2012 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/4326743 to your computer and use it in GitHub Desktop.
Save anonymous/4326743 to your computer and use it in GitHub Desktop.
def get_session():
session = was.orm.Session(bind=engine)
flask.g.session = session
flask.g.session_got = True
return flask.g.session
@before_request
def define_session():
flask.g.session = werkzeug.local.LocalProxy(get_session)
@teardown_request
def close_session():
if hasattr(flask.g, 'session_got'):
flask.g.session.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment