[Zope] How to call a python script within a Z-SQL method?

Julian Clark Julian.Clarke at b-online.com.au
Thu Nov 27 22:12:07 EST 2003


Hi Terry,

You understood me correctly.

Using a sql query called from within a python script, would you write the
query within the script? or would you call a seperate sql method from the
script?
Maybe I'm thinking in the wrong direction, but if the first case is correct,
how would you specify the database connection that you would use for the sql
from within the script?
(apologies if this is a stupid question, I'm still relatively new to python,
and I'm only now getting the hang of dtml)

Cheers,

Julian




-----Original Message-----
From: Terry Hancock [mailto:hancock at anansispaceworks.com]
Sent: Thursday, 27 November 2003 2:56 AM
To: zope
Cc: Julian Clark
Subject: Re: [Zope] How to call a python script within a Z-SQL method?


It was very unclear to me what you actually are trying to
do here.  The subject line is easy -- you can call python
scripts exactly as you would from any other DTML:

<dtml-var expr="compute_entry_date(ham, spam)">

The result will be *rendered into the query* and then sent
to the SQL engine to return an SQL results object.

But your description clouds this.  It sounds like you
actually want to do the query and then call a python
script to act on the *results of the query* not the *query*.

If that's the case, you need to wrap the SQL in a python
script call -- i.e. you don't want to call python from SQL,
you want to call an SQL query from python.  That's not
too hard, though -- the results object behaves very much
like a python sequence.

If you want to see what you're working with, just return the
object or a str() conversion of it so you can see the
output.

I think you might have to rephrase your question in those
terms if it still isn't clear what you need to do.

Cheers,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com




More information about the Zope mailing list