[Zope] Return success or fail from ZSQL method

Dieter Maurer dieter@handshake.de
Fri, 8 Jun 2001 20:23:20 +0200 (CEST)


Sion Morris writes:
 > How do I return a success or failure flag from the ZSQLMethod to DTML 
 > Method x? Does the ZSQL Method return anything once it has done it's 
 > operation?
I know of only a single way, a Z SQL Method can signal failure:

  it raises an exception

This exception is propagated until it hits an exception
handler.

There is an exception handler in ZPublisher.
It will turn the exception into a 500 HTTP response (internal server error).

If you do not like this failure indication, you need to catch
the exception earlier. You will need the "try: ... except:..."
clause in Python script or the "dtml-try" tag in DTML.

See (e.g.)

  URL:http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html

for details.


Dieter