[Zope] Passing parameters using DTML
John Poltorak
jp at warpix.org
Mon Jun 20 05:40:49 EDT 2005
On Fri, Jun 17, 2005 at 05:39:23PM -0500, J Cameron Cooper wrote:
> >>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'.
Many thanks. I appreciate the help. I think I've incorporated your
suggestion into the code below...
<html>
<body>
<span
tal:define="opts
python:here.parse_file(file=getattr(context,options.parm),sepr=',',clone=1)">
<tal:block repeat="opt opts">
<li><a tal:content="python:opt[1]"
tal:attributes="href python:opt[0]"></a></li>
</tal:block>
</span>
</body>
</html>
Unfortunately, when I try to use this expression
<dtml-var expr="testlist(parm='links')">
I get this Zope error:-
Error Type: AttributeError
Error Value: 'dict' object has no attribute 'parm'
Can't help thinking it is a simple syntax error - missing bracker, quote
etc... but just can't figure it out.
> --jcc
>
> --
> "Building Websites with Plone"
> http://plonebook.packtpub.com/
>
> Enfold Systems, LLC
> http://www.enfoldsystems.com
--
John
More information about the Zope
mailing list