On Nov 18, 7:48 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Matt Wilson schrieb:
>
>
>
> > I'm trying to wrap a trivial WSGI app with WebError so I can see how
> > it works.  I've got a wsgi script I'm running with mod_wsgi and the
> > script looks like this:
>
> > def myapp(environ, start_response):
>
> >     start_response('500 Internal Error', [('Content-Type', 'text/
> > plain')])
> >     1/0 # sometimes I comment this out
> >     return ['Returning 500']
>
> > from weberror.errormiddleware import ErrorMiddleware
> > application = ErrorMiddleware(myapp, debug=True)
>
> > When I run this with or without commenting out the 1/0 line, I don't
> > get anything like a viewable traceback.
>
> > I suspect I'm making some trivial mistake.  Any pointers?
>
> I don't know - but I wouldn't consider the above an error. If you want
> to show a 500 for some reason, that's perfecly legal.
>
> Instead, try & throw an exception insid myapp and see what happens.

$ python
Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero

So, what he is doing should achieve the same outcome as explicitly
throwing an exception.

I'd suggest throwing in some debug statements which log to sys.stderr
and then look in Apache error log. Eg.

  print >> sys.stderr, 'try to die'
  1/0
  print >> sys.stderr, 'should have died'

This will at least verify that your code is at least running and where
it gets too.

Graham
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to