Python 我可以移动biker.SessionMiddleware以处理方法吗?
有点难看的是,许多代码行落入Python 我可以移动biker.SessionMiddleware以处理方法吗?,python,fastcgi,beaker,Python,Fastcgi,Beaker,有点难看的是,许多代码行落入“\uuuuu main\uuuuu”。 有人能告诉我如何将SessionMiddleware移动到handle方法中吗? 我应该注意到我在CoreXmlParser中使用了会话。 提前谢谢 def handle(environ, start_response): req = webob.Request(environ) c = CoreXmlParser(req) resp = webob.Response(body=
“\uuuuu main\uuuuu”
。
有人能告诉我如何将SessionMiddleware移动到handle方法中吗?
我应该注意到我在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()
我不太明白你为什么只移动一行。如果您想减少“
\uuu main\uuuu
”中的内容量,为什么不将所有“\parse config file
”内容移动到一个单独的函数中呢
def handle(environ, start_response):
# same as before
def create_app(config_file):
#parse config file for session options
return SessionMiddleWare(handle, some_session_opts_here)
if __name__ == '__main__':
app = create_app(config_file)
from flup.server.fcgi import WSGIServer
WSGIServer(app).run()