[Zope] howto sql-query directly from my products methods?
Joel Burton
joel@joelburton.com
Mon, 4 Mar 2002 15:45:45 -0500 (EST)
On Mon, 4 Mar 2002, hans wrote:
> well, i could instantiate a bunch of zsql methods, each with
> its own query and then call them from my products methods.
> but how could i obviate the need to have these zsql methods
> and query directly? Or is it just not worth it?
> thx hans
Either:
. write a single ZSQL method with the text <dtml-var SQL_statement>
and put a prewritten SQL_statement var in the param list for the
ZSQL method.
or
. WRite a Py external method that queries the DB and returns the results
#1 is a tiny bit of hack but works fine, can still use ZSQLMethods
caching, etc. It just gives you a chance to move some of the
SQL-statement-crafting logic elsewhere rather than in DTML-in-ZSQMethod.
#2 is too low-level for my tastes: it would need to be edited for
different databases, wouldn't be cached like ZSQL Methods, etc.
--
Joel BURTON | joel@joelburton.com | joelburton.com | aim: wjoelburton
Independent Knowledge Management Consultant