![](https://secure.gravatar.com/avatar/1e2caa78f917e18fc081fed2f2058af7.jpg?s=120&d=mm&r=g)
Le 17/11/2012 11:17, Stefan Behnel a écrit :
The use case is to freely (and efficiently) mix in-memory
trees with incrementally generated content, and to safely write everything out into a file as it is being generated.
Maybe I'm not seeing something obvious, but how would this work in the WSGI case where you have to yield bunch of strings instead of writing to a file-like object? It's a different use case, although a valid one. I can't see a way to merge the two. The above is a push interface, whereas the WSGI case uses a pull interface.
It’s possible to wrap code that uses a .write() method into an iterator using greenlets: http://werkzeug.pocoo.org/docs/contrib/iterio/ Or, more generally: to convert a push interface into a pull interface using coroutines. Of course, the error handling issues that Stefan mentions still apply. Cheers, -- Simon Sapin