On 9 January 2011 12:16, Alice Bevan–McGregor <al...@gothcandy.com> wrote: > On 2011-01-08 09:00:18 -0800, P.J. Eby said: > >> (The next interesting challenge would be to integrate this withGraham's >> proposal for adding cleanup handlers...) > > class MyApplication(object): > def __init__(self): > pass # process startup code > > def __call__(self, environ): > yield None # must be a generator > pass # request code > > def __enter__(self): > pass # request startup code > > def __exit(exc_type, exc_val, exc_tb): > pass # request shutdown code -- regardless of exceptions > > We could mandate context managers! :D (Which means you can still wrap a > simple function in @contextmanager.)
Context managers don't solve the problem I am trying to address. The 'with' statement doesn't apply context managers to WSGI application objects in way that is desirable and use of a decorator to achieve the same means having to replace close() which is what am trying to avoid because of extra complexity that causes for WSGI middleware just to make sure wsgi.file_wrapper works. We want a world where it should never be necessary for WSGI middleware, or proxy decorators, to have to fudge up a generator and override the close() chain to add cleanups. Graham > - Alice. > > > _______________________________________________ > Web-SIG mailing list > Web-SIG@python.org > Web SIG: http://www.python.org/sigs/web-sig > Unsubscribe: > http://mail.python.org/mailman/options/web-sig/graham.dumpleton%40gmail.com > _______________________________________________ Web-SIG mailing list Web-SIG@python.org Web SIG: http://www.python.org/sigs/web-sig Unsubscribe: http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com