librelist archives

« back to archive

patch for wsgi.errors

patch for wsgi.errors

From:
antoine
Date:
2011-08-09 @ 08:02
Hi,

I played around wsgid to see if I could serve (it did work flawlessly
in the end) some mercurial repository and in order to please the hgweb
wsgi application I had to patch core/wsgid.py to add the wsgi.errors
environment variable.

As described here it seems to be mandatory :
http://www.python.org/dev/peps/pep-3333/#environ-variables


diff --git a/wsgid/core/wsgid.py b/wsgid/core/wsgid.py
index 023639e..8e5302a 100644
--- a/wsgid/core/wsgid.py
+++ b/wsgid/core/wsgid.py
@@ -4,6 +4,7 @@ import urllib
 from ..core import Message, StartResponse, get_main_logger
 import zmq
 from StringIO import StringIO
+import sys

 class Wsgid(object):

@@ -104,6 +105,7 @@ class Wsgid(object):
     environ['wsgi.multithread'] = False
     environ['wsgi.multiprocess'] = True
     environ['wsgi.run_once'] = True
+    environ['wsgi.errors'] = sys.stderr
     environ['wsgi.version'] = (1,0)
     self._set(environ, 'wsgi.url_scheme', "http")



Sincerely,
Antoine

Re: [wsgid] patch for wsgi.errors

From:
Dalton Barreto
Date:
2011-08-09 @ 16:50
2011/8/9 antoine <antoine@delaunay.org>:
> Hi,
>
> I played around wsgid to see if I could serve (it did work flawlessly
> in the end) some mercurial repository and in order to please the hgweb
> wsgi application I had to patch core/wsgid.py to add the wsgi.errors
> environment variable.
>

This is great, Antonie. I'm glad wsgid worked nice for you. Could you
tell me more about this applications so I can
run some tests myself? I'm just curious, I would like to know all
kinds of different applications I can run with wsgid.


> As described here it seems to be mandatory :
> http://www.python.org/dev/peps/pep-3333/#environ-variables
>
>
> diff --git a/wsgid/core/wsgid.py b/wsgid/core/wsgid.py
> index 023639e..8e5302a 100644
> --- a/wsgid/core/wsgid.py
> +++ b/wsgid/core/wsgid.py
> @@ -4,6 +4,7 @@ import urllib
>  from ..core import Message, StartResponse, get_main_logger
>  import zmq
>  from StringIO import StringIO
> +import sys
>
>  class Wsgid(object):
>
> @@ -104,6 +105,7 @@ class Wsgid(object):
>     environ['wsgi.multithread'] = False
>     environ['wsgi.multiprocess'] = True
>     environ['wsgi.run_once'] = True
> +    environ['wsgi.errors'] = sys.stderr
>     environ['wsgi.version'] = (1,0)
>     self._set(environ, 'wsgi.url_scheme', "http")
>
>
>
> Sincerely,
> Antoine
>

Indeed it's mandatory. I will apply your patch and this will be
available in the next release (0.3.0).

Thank you very much.

-- 
Dalton Barreto
http://daltonmatos.wordpress.com
http://wsgid.com

Re: [wsgid] patch for wsgi.errors

From:
Dalton Barreto
Date:
2011-08-10 @ 00:29
2011/8/9 Dalton Barreto <daltonmatos@gmail.com>:
> 2011/8/9 antoine <antoine@delaunay.org>:
>> Hi,
>>
>> I played around wsgid to see if I could serve (it did work flawlessly
>> in the end) some mercurial repository and in order to please the hgweb
>> wsgi application I had to patch core/wsgid.py to add the wsgi.errors
>> environment variable.
>>
>
> This is great, Antonie. I'm glad wsgid worked nice for you. Could you
> tell me more about this applications so I can
> run some tests myself? I'm just curious, I would like to know all
> kinds of different applications I can run with wsgid.
>
>
>> As described here it seems to be mandatory :
>> http://www.python.org/dev/peps/pep-3333/#environ-variables
>>
>>
>> diff --git a/wsgid/core/wsgid.py b/wsgid/core/wsgid.py
>> index 023639e..8e5302a 100644
>> --- a/wsgid/core/wsgid.py
>> +++ b/wsgid/core/wsgid.py
>> @@ -4,6 +4,7 @@ import urllib
>>  from ..core import Message, StartResponse, get_main_logger
>>  import zmq
>>  from StringIO import StringIO
>> +import sys
>>
>>  class Wsgid(object):
>>
>> @@ -104,6 +105,7 @@ class Wsgid(object):
>>     environ['wsgi.multithread'] = False
>>     environ['wsgi.multiprocess'] = True
>>     environ['wsgi.run_once'] = True
>> +    environ['wsgi.errors'] = sys.stderr
>>     environ['wsgi.version'] = (1,0)
>>     self._set(environ, 'wsgi.url_scheme', "http")
>>
>>
>>
>> Sincerely,
>> Antoine
>>
>
> Indeed it's mandatory. I will apply your patch and this will be
> available in the next release (0.3.0).
>

Patch applied! 
https://github.com/daltonmatos/wsgid/commit/b3c9b73dbfc4051199cd042be356a85e7ea34a4b
Thank you very much!

And sorry for misspelling your first name on my mail reply. =)


-- 
Dalton Barreto
http://daltonmatos.wordpress.com
http://wsgid.com

Re: [wsgid] patch for wsgi.errors

From:
antoine
Date:
2011-08-11 @ 09:04
it really is nothing fancy, I grabbed the following from the hg documentation :


from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb.hgwebdir_mod import hgwebdir
application = hgwebdir('/path/to/hgweb.config')


not knowing any better I created an app and logs directory, and pasted
those lines in $WSGI_TEST/apps/wsgi.py

The hgweb.config itself it the simple :


[web]
style = coal
[paths]
abiec = /path/to/hg-repository


to start the server I used  :


python wsgid_develop/wsgid_start.py --app-path=$WSGI_TEST
--wsgi-app=wsgi.application --recv=tcp://127.0.0.1:9997
--send=tcp://127.0.0.1:9996 --no-daemon


Antoine

On Tue, Aug 9, 2011 at 6:50 PM, Dalton Barreto <daltonmatos@gmail.com> wrote:
> 2011/8/9 antoine <antoine@delaunay.org>:
>> Hi,
>>
>> I played around wsgid to see if I could serve (it did work flawlessly
>> in the end) some mercurial repository and in order to please the hgweb
>> wsgi application I had to patch core/wsgid.py to add the wsgi.errors
>> environment variable.
>>
>
> This is great, Antonie. I'm glad wsgid worked nice for you. Could you
> tell me more about this applications so I can
> run some tests myself? I'm just curious, I would like to know all
> kinds of different applications I can run with wsgid.
>
>
>> As described here it seems to be mandatory :
>> http://www.python.org/dev/peps/pep-3333/#environ-variables
>>
>>
>> diff --git a/wsgid/core/wsgid.py b/wsgid/core/wsgid.py
>> index 023639e..8e5302a 100644
>> --- a/wsgid/core/wsgid.py
>> +++ b/wsgid/core/wsgid.py
>> @@ -4,6 +4,7 @@ import urllib
>>  from ..core import Message, StartResponse, get_main_logger
>>  import zmq
>>  from StringIO import StringIO
>> +import sys
>>
>>  class Wsgid(object):
>>
>> @@ -104,6 +105,7 @@ class Wsgid(object):
>>     environ['wsgi.multithread'] = False
>>     environ['wsgi.multiprocess'] = True
>>     environ['wsgi.run_once'] = True
>> +    environ['wsgi.errors'] = sys.stderr
>>     environ['wsgi.version'] = (1,0)
>>     self._set(environ, 'wsgi.url_scheme', "http")
>>
>>
>>
>> Sincerely,
>> Antoine
>>
>
> Indeed it's mandatory. I will apply your patch and this will be
> available in the next release (0.3.0).
>
> Thank you very much.
>
> --
> Dalton Barreto
> http://daltonmatos.wordpress.com
> http://wsgid.com
>

Re: [wsgid] patch for wsgi.errors

From:
Dalton Barreto
Date:
2011-08-11 @ 13:48
2011/8/11 antoine <antoine@delaunay.org>:
> it really is nothing fancy, I grabbed the following from the hg documentation :
>
>
> from mercurial import demandimport; demandimport.enable()
> from mercurial.hgweb.hgwebdir_mod import hgwebdir
> application = hgwebdir('/path/to/hgweb.config')
>
>
> not knowing any better I created an app and logs directory, and pasted
> those lines in $WSGI_TEST/apps/wsgi.py
>
> The hgweb.config itself it the simple :
>
>
> [web]
> style = coal
> [paths]
> abiec = /path/to/hg-repository
>
>
> to start the server I used  :
>
>
> python wsgid_develop/wsgid_start.py --app-path=$WSGI_TEST
> --wsgi-app=wsgi.application --recv=tcp://127.0.0.1:9997
> --send=tcp://127.0.0.1:9996 --no-daemon
>

Great, thank you!

I'll take a closer look at this later.

-- 
Dalton Barreto
http://daltonmatos.wordpress.com
http://wsgid.com