nginx git repository

Manlio Perillo manlio_perillo at libero.it
Sun Oct 14 17:31:05 MSD 2007


Adrian Perez ha scritto:
> Hello,
> 
> First of all, sorry for the late reply, I have been quite busy lately.
> 

No problem.
I have just released the new version of mod_wsgi, and it took me a lot 
of time!

Now it should be easy to add support for WSGI 1.0, I hope to release the 
next version on the next weekend.

 > [...]
>> Can you send me the logs?
>> The log level should be "info";
> 
> I will re-run the tests with log level set to "info", but I will first
> update to the latest revision of the mod_wsgi module. 

Ok, thanks.

> I am using the
> following Python snippet to adapt WSGI 1.0 apps to 2.0, they are a set
> of decorators for WSGI applications, I hope they are ok although I have
> not read the WSGI standard in depth:
> 
> ---- <snip> ----
> 
> class Context(object):
>     __slots__ = ("response", "headers")
> 
>     def __init__(self):
>         self.response = None
>         self.headers  = ()
>     def __call__(self, response, headers):
>         self.response = response
>         self.headers  = headers
> 
> 
> def wsgi1to2(application):
>     """Converts a 1.0 app into a 2.0 app"""
>     def wrapper(environ):
>         context = Context()
>         results = application(environ, context)
>         return context.response, context.headers, results
>     return wrapper
> 

This seems ok.

It is not fully WSGI compliant, however, since a WSGI application can 
call start_response inside the returned generator, but this should not 
be a problem since common WSGI applications just returns a list as result.

I will do some tests.


> 
> def returnone(application):
>     """Makes a 2.0 app return only one element as result"""
>     def wrapper(environ):
>         response, headers, results = application(environ)
>         return response, headers, "".join(results)

Here you should do "".join(list(results)), since results can be a generator.

However now returnone is no more necessary.

>     return wrapper
> 
> 
> def fornginx(application):
>     """Applies the two above decorators, which is needed for
>        a 1.0 application to work inside Nginx.
>     """
>     return returnone(wsgi1to2(application))
> 
> ---- </snip> ----
> 
> Cheers,
> 


Regards and thanks for the support
Manlio Perillo





More information about the nginx mailing list