[Zope] Zope bug or my stupidity?
Curtis Maloney
curtis@umd.com.au
Wed, 16 Aug 2000 10:51:29 +1000
On Wed, 16 Aug 2000, Peter Hernberg wrote:
> --- Chris Withers <chrisw@nipltd.com> wrote:
> > Peter Hernberg wrote:
> > > Here's the method that calls that method:
> > > <dtml-var "get_storys">
> >
> > Why the quotes?
> >
> > try <dtml-var get_storys> instead
>
> But then I get the following weird error:
> Traceback (innermost last):
*snip*
> (Object: objectValues('Story'))
> File /root/Zope-2.2.0-src/lib/python/DocumentTemplate/DT_Util.py, line
> 337, in eval
> (Object: sequence-index == 0)
> (Info: index)
> File <string>, line 0, in ?
> NameError: (see above)
>
> I am fairly new to zope, but this seems pretty weird, especially the method
> returning its dtml source.
And you've been caught by one of the most common (and understandable) newbie
mistakes. (o8.
'sequence-item' is not a valid Python name. To Python it looks like "
sequence - item ", the mathematical expression.
This is a holdover from days of old, and not much has been done to deprecate
it (all my shouting, and that of others, has so far come to naught.)
<dtml-var sequence-item> will work, because that is in Zope Land... no
quotes.
<dtml-var "_['sequence-item']"> is the Python Land equivalent. the _[] name
space lookup is your friend for this sort of problem.
<dtml-if "sequence-index < (numStories - 1)">
should be written as:
<dtml-if "_['sequence-index'] < (numStories -1)">
>
> =====
> Peter Hernberg
> An all-purpose, antibacterial, lemon-scented geek/nerd
>
I guess I should really try to rally people to send this to the collector...
Have a better one,
Curtis Maloney.
<dtml-var standard_work_disclaimer>