Commit 4ebe99ec authored by Julien Cigar's avatar Julien Cigar
Browse files

added sa tool

parent 7f0b5e61
# -*- coding: utf-8 -*-
import cherrypy
__all__ = ['SATool']
class SATool(cherrypy.Tool):
def __init__(self):
super(SATool, self).__init__('on_start_resource', self.bind_session,
priority=20)
def _setup(self):
super(SATool, self)._setup()
cherrypy.serving.request.hooks.attach('on_end_resource',
self.remove_session, priority=80)
def bind_session(self):
self.session = cherrypy.engine.publish('get-session').pop()
def remove_session(self):
if not self.session:
return
self.session.remove()
self.session = None
Markdown is supported
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