hi
the helper for class for making middleware a processor is not working.. i
have given the code below... do you know what is wrong?

On Wed, Nov 19, 2008 at 2:22 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>wrote:

> anand thanks for the helper class.. but it is not working...
> the middleware is not getting processed....
>
> do you know what is wrong?
>
> is this the right way of doing it?
>
>
> subdomain app bt/code.py
>
> from beaker.middleware import SessionMiddleware
> def beak_session_mw(app):
>     return SessionMiddleware(app, **options)
>
> app = web.application(urls, globals())
> app.add_processor(middleware(beak_session_mw))
>
>
>
>
> main app file
>
> from bt.code import app
> mapping = ("www.XXXX.com", app)
> x = web.subdomain_application(mapping)
> if __name__ == "__main__":
>     x.run()
>
>
>
> http://0.0.0.0:8080/
> Traceback (most recent call last):
>   File "/home/mark/work/common/web/application.py", line 211, in wsgi
>     result = self.handle_with_processors()
>   File "/home/mark/work/common/web/application.py", line 183, in
> handle_with_processors
>     return process(self.processors)
>   File "/home/mark/work/common/web/application.py", line 180, in process
>     return self.handle()
>   File "/home/mark/work/common/web/application.py", line 486, in handle
>     return app.handle()
>   File "/home/mark/work/common/web/application.py", line 172, in handle
>     return self._delegate(fn, self.fvars, args)
>   File "/home/mark/work/common/web/application.py", line 361, in _delegate
>     return handle_class(cls)
>   File "/home/mark/work/common/web/application.py", line 336, in
> handle_class
>     return tocall(*args)
>   File "/home/mark/work/bt/user.py", line 192, in proxyfunc
>     web.ctx.environ['session'] = web.ctx.environ['beaker.session']
> KeyError: 'beaker.session'
>
>
> 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