[Zope] Newbie question
Sam Gendler
sgendler@silcom.com
Sat, 22 Apr 2000 00:13:52 -0700
gpgreen@olywa.net wrote:
>
> On Sat, Apr 22, 2000 at 04:04:58PM +1000, Malcolm Tredinnick wrote:
> > The syntax you want, if I've understoof the question, is (untested):
> > <dtml-var "the_other_dtml_method(_['sequence-item'])">
> >
> > You need to do it this way because the stuff inside the quotes is a python
> > expression and hyphens are not permitted in Python variable names. So you use
> > the magical _ namespace, which contains things like sequence-item as a key.
>
> Very nice. Now how do I reference the variable in the_other_dtml_method? I
> assume it is in the other methods namespace, but what name does it have?
>
> --
> Greg Green
> e-mail: gpgreen@olywa.net
> http://www.olywa.net/gpgreen/
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
It doesn't need a name. It will be the only variable available. Call
it whatever you want. Declare the external method as 'def
otherExternalMethod(self, my_var):', and the sequence-item is available
in my_var, and you can access the current folder in self. You can
always call the second method as <dtml-var
"otherExtMethod(my_var=_['sequence-item'])"> (I think, untested).
Just a note... loops in dtml are relly inefficient. If it is at all
possible, pass the entire list into the second method, and iterate
through the list in python. It will be MUCH faster.
--sam