【发布时间】:2011-06-08 08:00:12
【问题描述】:
使用以下示例代码:
from webob import Response
from paste.httpserver import serve
def test_iter():
from pyramid import threadlocal
yield 'current request: %s' % threadlocal.get_current_request()
def hello_world(request):
return Response(app_iter=test_iter())
if __name__ == '__main__':
from pyramid.config import Configurator
config = Configurator()
config.add_view(hello_world)
app = config.make_wsgi_app()
serve(app, host='0.0.0.0')
我得到当前请求:无。那么,threadlocal 在app_iter 中不起作用?我有实际代码,我需要访问远离视图几层的threadlocal,并且传递request 变量会很麻烦。
【问题讨论】:
标签: python pyramid thread-local webob