[ZPT] RE: [Zope-DB] Text in Query Question

Fernando Martins fmartins at hetnet.nl
Fri Jun 27 22:06:47 EDT 2003


From: Rima Gerhard
> > > Say that I have a table called "artshows" which
> > > has a column
> > > description. In the description, I want to query another table and
> >insert
> > > something like
> > > "The artshow is taking place at <span tal:repeat="in
> > > python:root.selectLocation(art_id='23')"><a href="link"
> > > tal:attributes="href
> > > in/linktowebpage">location</a></span>.
> > >
> > > Right now, the query inside of the columns doesn't get
> executed by Zope.
> > > Does anyone have any idea how to work around this problem?
> >
> >Hmm, I suspect the problem is here: art_id='23'. Why not use art_id=23?
> >What
> >is the type of the column art_id. What is your ZSQL method? Have
> you tested
> >it in the ZMI?
>
> Oh that was simply an example. I was more wondering how it would
> be possible
> to insert a query into something that is in itself the result
> from a query.
> The ZSQL method would be
> select description
> from artshows
>
> and description is a string field that contains a call to another zsql
> method.
> any ideas...?

This is not a DB problem but a ZPT one (I've cc'ed the list). You have to
create a Python Script, say parseDescription, and pass it your
'description'.  In this script, you need to call some (which one?) API
function that accepts your 'description' as a ZPT source and returns the
resulting HTML. E.g.:

   return container.SomeAPIfunction(description)

In your PageTemplate you have to call the script like this:

<p tal:content="structure
python:here.parseDescription(aRecordVariable.description)">

I'm just guessing SomeAPIfunction exists. Otherwise, you'll have to create a
page template (preferably in a temporary folder) with the contents of your
description and call it to get the HTML code. See this link on how to do it:

http://www.zopelabs.com/cookbook/993981399

Cheers,
Fernando




More information about the ZPT mailing list