Werkzeug v0.11 i使用函数ClosingIterator装饰了wsgi.py文件中的类Werkzeug的源代码:
wsgi.py
@implements_iterator
class ClosingIterator(object):
"""The WSGI specification requires that all middlewares and gateways
respect the `close` callback of an iterator. Because it is useful to add
another close action to a returned iterator and adding a custom iterator
is a boring task this class can be used for that::
return ClosingIterator(app(environ, start_response), [cleanup_session,
cleanup_locals])
If there is just one close function it can be passed instead of the list.
A closing iterator is not needed if the application uses response objects
and finishes the processing if the response is started::
try:
return response(environ, start_response)
finally:
cleanup_session()
cleanup_locals()
"""我在文件implements_iterator中找到了_compat.py的定义:
implements_iterator = _identity
_identity = lambda x: x问题是: implements_iterator的功能是什么?
https://stackoverflow.com/questions/46376804
复制相似问题