多行代码落入"__main__"
. 有人可以告诉我如何将 SessionMiddleware 移动到句柄方法中吗?我应该注意到我在 CoreXmlParser 中使用了会话。提前致谢 !
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()