Also in trunk, experimental, ability to decorate web2py actions that
return strings with third party WSGI middleware. Example:
#define or import WSGI Middleware
class MiddlewareUpper:
def __init__(self,app):
self.app = app
def __call__(self,environ, start_response):
items = self.app(environ, start_response)
return [item.upper() for item in items]
@request.wsgi.middleware(MiddlewareUpper)
def index():
return 'hello world'
Not sure I would recommend this. It may be slow. But you can. Give it
a try and let me know.
Massimo
On Oct 29, 11:11 am, mdipierro <[email protected]> wrote:
> ERRATA: Fixed a problem in trunk and here is a better example:
>
> # sample test app
> def test_wsgi_app(environ, start_response):
> """just a test app"""
> status = '200 OK'
> response_headers = [('Content-type','text/plain'),('Content-
> Length','13')]
> start_response(status, response_headers)
> return ['hello world!\n']
>
> # sample controller action calling the wsgi app above
> def index():
> items = test_wsgi_app
> (request.wsgi.environ,request.wsgi.start_response)
> for item in items: response.write(item,escape=False)
> return response.body.getvalue()
>
> On Oct 29, 10:44 am, mdipierro <[email protected]> wrote:
>
> > This got buried in a previous thread but it is important. In trunk we
> > have and experimental feature:
>
> > request.wsgi.environ and request.wsgi.start_response
>
> > this means that you can now call ANY wsgi function from inside a
> > web2py action:
>
> > def index():
> > some_wsgi_app(request.wsgi.environ,request.wsgi.start_response)
> > request.wsgi.start_response(200)
> > return response.body.getvalue()
>
> > Now you can run a Django app in one controller and a CherryPy app in
> > another + the wsgi apps can access web2py sessions, auth decorators,
> > etc.
>
> > It is perverse but can be useful. If you test it please let me know if
> > it works for you.
>
> > Massimo
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---