Can I move beaker.SessionMiddleware to handle method somehow?

Posted by Alexander A.Sosnovskiy on Stack Overflow See other posts from Stack Overflow or by Alexander A.Sosnovskiy
Published on 2010-05-20T06:17:46Z Indexed on 2010/05/20 6:20 UTC
Read the original article Hit count: 238

Filed under:
|
|

It's a bit ugly that many lines of code fall into "__main__". Can someone give me a tip of how to move SessionMiddleware into handle method? I should notice that I use session in CoreXmlParser. Thanks in advance !

def handle(environ, start_response):
        req = webob.Request(environ)
        c = CoreXmlParser(req)
        resp = webob.Response(body=c(), charset = 'utf-8', status='200 OK', \
        request=req, content_type='text/xml')
        resp(environ, start_response)
        return resp.app_iter

    if __name__ == '__main__':
        #parse config file for session options
        app = SessionMiddleware(handle, some_session_opts_here)
        from flup.server.fcgi import WSGIServer
        WSGIServer(app).run()

© Stack Overflow or respective owner

Related posts about python

Related posts about beaker