[Zope] Passing parameters using DTML

J Cameron Cooper zope-l at jcameroncooper.com
Fri Jun 17 18:39:23 EDT 2005


John Poltorak wrote:
> On Fri, Jun 17, 2005 at 05:07:32PM -0400, Paul Winkler wrote:
> 
>>On Fri, Jun 17, 2005 at 08:24:23PM +0100, John Poltorak wrote:
>>
>>>Is there also something which explains how to call ZPTs from a DTML 
>>>object?
>>>
>>>I'm unable to pick up a passed parameter.
>>>
>>>This is what I've conjured up:-
>>>
>>>python:here.lib.parse_file(file=context.options['parm'],sepr=',',clone=1)"> 
>>>
>>>hoping that "options['parm']" would get resolved as "ABC" but it doesn't.
>>
>>John, please, *always* provide tracebacks instead of saying things
>>like "it doesn't".  
>>
>>
>>>Any ideas? 
>>
>>Without a traceback, everything I say below is guesswork.
>> 
>>I'm assuming the above line comes from a page template.
>>You neglected to mention what the calling DTML looks like,
>>but I *guess* that it was something like this:
>><dtml-var "some_template(parm='ABC')">
>>yes? no?
> 
> 
> This is what I have:-
> 
> <dtml-var expr="testlist(parm='myobjectname')">
> 
> I wish to get 'myobjectname' into this line in 'testlist' which is marked
> with *********
> 
> python:here.parse_file(file=context.******,sepr=',',clone=1)"> 
> 
> There must be a simple way of doing this, but I haven't come across an 
> example of it and I've spent most of the day on it.

Taking the options from my previous email and putting them together, you 
can say::

    python:here.parse_file(file=getattr(context,options.parm),...)

to get the attribute on the current context named 'myobjectname' or 
whatever else you provide as the 'parm' parameter on 'testlist'.

The ellipsis is just to eliminate elements unnecessary to the point.

		--jcc

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

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


More information about the Zope mailing list