[Zope] sequence-item is a String? (was: Calling objects with arguments in a
sequence)
sequence)
seb
sebbacon@email.com
Thu, 28 Sep 2000 11:26:36 +0100
Thanks very much for the reply, Tres. Unfortunately it didn't work.
I've been puzzling about this for a while, and I'm lost. I thought I'd
restate the problem in more generic terms in the hope that more people
will have a look at it.
If you do:
<dtml-in "objectValues('Foo Thing')">
<dtml-let thing=sequence-item>
<dtml-var "thing.id()">
</dtml-let>
</dtml-in>
You get TypeError: it claims thing is a string, so you can't perform any
kind of function call against it.
My understanding is that when the ZPublisher finds an object reference,
it invokes its __str__ method. This returns a string. When Zope finds
an object being called with parameters, it invokes its __call__ method,
which also (usually) returns a string.
I think that in the case of a sequence-item, the ZPublisher is invoking
the __str__ method of the object, and _then_ applying arguments to the
result, which is a string object. So, it fails.
Is this a bug? Is Zope rendering the object too soon? I've thought and
thought about this, but can't think of a logical reason for this
behaviour of sequence-item. Surely sequence-item should be a reference
to a normal object, and therefore behave like one? But then again, I'm
a Zope / python newbie, so *please* shoot me down ;)
With a furrowed brow,
Seb.
> <dtml-in "objectValues( [ 'Photo' ] )">
> <dtml-let photo=sequence-item> <!-- alias so we can use in expr! -->
> <dtml-var "photo( display='thumbnail' )">
> </dtml-let>
> </dtml-in>
>
> seb <sebbacon@email.com> wrote:
> >
> > I'm using the Photo product, instances of which I can call, with
> > arguments, like this:
> >
> > <dtml-var "my_photo(display='thumbnail')">
> >
> > However, I can't work out how to pass arguments to each sequence item
> > when iterating over a sequence.
> >
> > For example, I've tried:
> >
> > <dtml-in objectValues(['Photo'])">
> > <dtml-var "_['sequence-item'](display='thumbnail')">
> > </dtml-in>
> >
> > (..not that I expect that to work :)
> >
> > And I get
> >
> > Error Type: TypeError
> > Error Value: call of non-function (type string)