[Zope-dev] Stumped about handling this particular exception...
skip@mojam.com (Skip Montanaro)
skip@mojam.com (Skip Montanaro)
Tue, 27 Apr 1999 22:19:53 -0400
I asked this question in a different form before but got only silence from
the list. I'll give it another try...
I'm using ZServer and a snapshot of the Zope CVS directory. When a user of
the web site fails to input a required form element, ZServer spits out
Server Error: exceptions.ValueError, No input for required field<p>:
file: /home/dolphin/skip/src/Zope/lib/python/ZPublisher/Converters.py line: 114
on the controlling terminal and the user sees
Error response
Error code 500.
Message: Internal Server Error.
instead of a useful message that will help the user figure out what they did
wrong. This makes them think my web site is broken, when it's actually
their input that's broken...
I've tried tracing the control flow back from Converters.py. I manually
figured out the following call chain:
HTTPRequest.py, line 246
Publish.py, line 252
The three levels of try statement nesting in Publish.py made it unlikely
that I would figure out precisely what happens from the failed Request(). I
tried adding a little traceback printing to the field2required function:
def field2required(v):
if hasattr(v,'read'): v=v.read()
else: v=str(v)
if strip(v): return v
try:
raise ValueError, 'No input for required field<p>'
except:
import sys, traceback
ty, va, tb = sys.exc_info()
f = open("/tmp/traceback", "a")
f.write("\n\n---- %s, %s ----\n" % (ty, va))
traceback.print_tb(tb, None, f)
f.write("\n")
f.close()
raise
but all it dumps in /tmp/traceback is information for a single line:
---- exceptions.ValueError, No input for required field performers<p> ----
File "/home/killer-whale/skip/src/Zope/lib/python/ZPublisher/Converters.py", line 115, in field2required
raise ValueError, 'No input for required field %s<p>' % k
Any reason why it won't show me more of the execution stack?
I'm really flummoxed. Any feedback on this problem would be much
appreciated.
Skip Montanaro | Mojam: "Uniting the World of Music" http://www.mojam.com/
skip@mojam.com | Musi-Cal: http://www.musi-cal.com/
518-372-5583