[Web-SIG] [WSGI] mod_python wrapper: minimal first attempt

Robert Brewer fumanchu at amor.org
Thu Oct 14 23:20:07 CEST 2004


Phillip J. Eby wrote:
> At 11:20 PM 10/13/04 -0700, Robert Brewer wrote:
> >I wrote:
> > > Here's the revised version. I haven't tested everything; 
> for example,
> > > reading straight from wsgi.input or writing to .errors. 
> I'll wait for
> > > the bug reports. :)
> >
> >Okay. I just did file uploads (with cgi.FieldStorage) and naturally
> >encountered errors ;) which were printed to the apache2 error.log.
> >However, this did *not* happen in 
> BaseCGIHandler.log_exception because
> >the headers had already been set, which raised another 
> error, which also
> >got printed to error.log. Not sure what to do about that, if 
> anything.
> 
> Send me both tracebacks.  :)

Traceback (most recent call last):

  File "C:\Python23\lib\site-packages\mod_python\apache.py", line 299,
in HandlerDispatch
    result = object(req)

  File "C:\Python23\lib\site-packages\cation\html\uiwsgi.py", line 144,
in run_app
    self.run(self.app)

  File "C:\Python23\lib\site-packages\wsgiref\handlers.py", line 96, in
run
    self.handle_error()

  File "C:\Python23\lib\site-packages\wsgiref\handlers.py", line 307, in
handle_error
    self.result = self.error_output(self.environ, self.start_response)

  File "C:\Python23\lib\site-packages\wsgiref\handlers.py", line 325, in
error_output
    start_response(self.error_status, self.error_headers[:])

  File "C:\Python23\lib\site-packages\wsgiref\handlers.py", line 176, in
start_response
    raise AssertionError("Headers already set!")

AssertionError: Headers already set!

> One quick question: what is 'sys.stderr' for Python under 
> mod_python?  If 
> it prints to the error log, there's no reason (at least from 
> a compliance 
> POV) not to simply use it as the handler's stderr.

sys.stderr -> apache's error log. See
http://www.modpython.org/FAQ/faqw.py?req=show&file=faq02.003.htp


Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org


More information about the Web-SIG mailing list