a little wsgi framework
Hao Lian
me at haolian.org
Tue Jul 7 00:38:10 EDT 2009
timmyt wrote:
> i'm interested in getting opinions on a small wsgi framework i
> assembled from webob, sqlalchemy, genshi, and various code fragments i
> found on the inter-tubes
>
> here is the interesting glue - any comments / suggestions would be
> much appreciated
Fun! Since you're already using WebOb, you should
give webob.Response a try, which will handle your
headers in a sexier way. (If you start using
paste.httpexceptions and the middleware, you can
avoid manually sending headers altogether.)
http://pythonpaste.org/webob/reference.html#response-as-a-wsgi-application
http://pythonpaste.org/modules/httpexceptions.html#paste.httpexceptions.HTTPExceptionHandler
timmyt wrote:
> global config
>
> try:
> return_dict = target(request, start_response)
> return_string = template.generate(**return_dict).render
> (method)
> config['database.Session'].commit()
> except:
> config['database.Session'].rollback()
> raise
> finally:
> config['database.Session'].remove()
The config global probably isn't thread-safe
depending on what you're doing with the
application. A safer way to go would be use Paste
Registry like Pylons does with its globals or just
attach it to Request.
http://pythonpaste.org/webob/reference.html#ad-hoc-attributes
More information about the Python-list
mailing list