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.)

        - 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/archive%40mail-archive.com

Reply via email to