Mercurial > hg > webob_view
view webob_view/template/+package+/+package+.py_tmpl @ 1:eb2cb7ebc849
moving to a handler architecture
author | k0s <k0scist@gmail.com> |
---|---|
date | Thu, 29 Oct 2009 15:08:54 -0400 |
parents | 72cb6dc31e3f |
children |
line wrap: on
line source
""" ${repr(project)}: a view with webob """ from handlers import Get, Post from webob import Request, exc class Dispatcher(object): ### class level variables defaults = {} def __init__(self, **kw): for key in self.defaults: setattr(self, key, kw.get(key, self.defaults[key])) self.handlers = [ Get, Post ] ### methods dealing with HTTP def __call__(self, environ, start_response): request = Request(environ) for h in self.handlers: if h.match(request): handler = h(request) break res = handler() return res(environ, start_response)