is this being added to
web.contrib
or some place in main webpy git
thanks

On Wed, Nov 19, 2008 at 6:57 AM, Anand Chitipothu <[EMAIL PROTECTED]>wrote:

>
> sorry, there was a typo. Here is the corrected version.
>
> import web
>
> class middleware:
>    """Helper to convert wsgi middleware to application processor.
>    Usage:
>
>        app.add_processor(middleware(mw))
>    """
>    count = 0
>    def __init__(self, middleware):
>        self.name = self._get_name()
>        self.wsgi = middleware(self.fake_wsgi_app)
>
>    def _get_name(self):
>        middleware.count += 1
>        return "_wsgi_middleware_handler_%d" % (middleware.count)
>
>    def __call__(self, handler):
>        web.ctx[self.name] = handler
>
>        environ = web.ctx.environ
>        def start_response(status, headers):
>            web.ctx.status = status
>            web.ctx.headers = headers
>        return self.wsgi(environ, start_response)
>
>    def fake_wsgi_app(self, environ, start_response):
>        handler = web.ctx[self.name]
>        try:
>            out = handler()
>        except web.HTTPError, e:
>            out = e.data
>        start_response(web.ctx.status, web.ctx.headers)
>        return out
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to