[Zope-dev] Z SQL Method Patch

T.J. Mannos MannosTJ@slcc.edu
Mon, 11 Sep 2000 10:41:24 -0600


Casey,

I just wanted to thank you very, very, VERY much for that tip!  I've spent
far too many hours debugging very long, complex Z SQL methods.  This will be
an enormous help!  By the way, it works like a charm on ZMySQLDA.

Thanks!
- T.J.

-----Original Message-----
From: zope-dev-admin@zope.org [mailto:zope-dev-admin@zope.org]On Behalf
Of Casey Duncan
Sent: Thursday, September 07, 2000 4:26 PM
To: zope-dev@zope.org
Subject: [Zope-dev] Z SQL Method Patch


In debugging some Z SQL methods I found it quite hard to diagnose certain
errors returned by the database backend because Zope doesn't return the SQL
sent to the server, instead it returns "Could not render the query
template!" which is not really true for this case.

In looking at the source code of DA.py (lib/python/Shared/DC/ZRDB), and I
think I found a simple solution:

in manage_test insert the following indented after line 343 (except:)

try: src=self(REQUEST, src__=1)
except: pass

This re-renders the query template if possible without sending it to the
backend and returns the SQL in src. The result is your backend error message
followed by the SQL generated. This should really save time debugging any
dynamic Z SQL methods.

It was moderately tested on Zope 2.2.1/PostgreSQL 7 via PyGreSQLDA. It
should not be database dependant though.

Enjoy.
-Casey Duncan