[Zope-DB] Access ZPT variable from ZSQL

Charlie Clark charlie at egenix.com
Fri Nov 5 12:27:02 EST 2004

On 2004-11-03 at 16:22:33 [+0100], Philip Kilner <phil at xfr.co.uk> wrote:
> Sorry - was a rushed question, as I was on my way out of the door.
> - I have three tables in my dB, which represent a hierarchy. For ease,
> let's call them G(randfather), F(ather) and S(on).
> - Within each row of the "G" recordset, I list the related "F" records,
> within each row of each "F" recordset I list the "S" records.
> - I use a common template for each level, and pass parameters to it from
> it's parent.
> - In this case, the "G" recordset is filtered by a request variable -
> easy. Let's say our Grandfathers are Tom, Dick and Harry - so in the
> "Tom" row, I want to nest a list of Tom's children from the "F" recordset.
> - In the ZPT, I can print out the variable ("Tom"), no problem.
> - In the ZSQL, I'm trying to figure out how to access this variable.
> In fact, I've got around this by calling the ZSQL method from the ZPT
> with explicit parameters: -
> <div tal:define="trackelements
> python:here.qual_track_element_recordset_sql(TrackRef=TrackRef)">
> However, this is putting some non-presentation logic in my ZPT which
> doesn't feel right - so I'd like to be able to access it directly from
> the ZSQL if I could...

I'm still not quite sure what you're doing but I think it might be possible 
to do things with zpt-options. Surely the rest should be easy assuming your 
hierarchy is correctly modelled.

<tal:define="db options/db; results python:here.myZSQL(db=db)">

Charlie Clark

Professional Python Services directly from the Source
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::

More information about the Zope-DB mailing list