[Zope] Please help with DTML-in (newbie)

J Cameron Cooper zope-l at jcameroncooper.com
Wed Dec 28 16:29:24 EST 2005


Alric Aneron wrote:
>  Hello, I am new to Zope and DTML.
> I am trying to use a python script to call a Z SQL method.  The python 
> script also has a list that <dtml-in inside the ZSQL method interates 
> over. so my python script:
> -----python script
> words = ['one', 'two']
> context.REQUEST.set('wordlist', wordlist)
> rs = context.myzsqlmethod()
> return rs[0,2]
> -----z sql script:
> SELECT * FROM table
> WHERE
> <dtml-in words>
> column1 LIKE ('<dtml-var "'%'+sequence-item+'%'">' OR
> column2 LIKE '<dtml-var "'%'+sequence-item+'%'">') <dtml-unless 
> sequence-end> AND </dtml-unless>
> </dtml-in>
> ---------------
> But it doesn't want to, gives me..
> *Error Type: NameError*
> *Error Value: name 'wordlist' is not defined
> 
> *I tried feeding the variable into the ZSQL arguments list, but i got 
> something like "cannot concatenate a module with a str"
> Can anyone please help me?
> Thank you!

It complains about 'wordlist' because it is not defined anywhere. 
Perhaps you mean 'words' in the second line?

To pass a param to the ZSQL method, just say::

    context.myzsqlmethod(words=words)

This will put it in the namespace.

		--jcc
-- 
"Building Websites with Plone"
http://plonebook.packtpub.com/

Enfold Systems, LLC
http://www.enfoldsystems.com


More information about the Zope mailing list