[Zope] Re: ZPT with Zope 3 queries - repeat over contained items

Jim Vine jim_a_vine at yahoo.co.uk
Tue Jul 5 16:25:33 EDT 2005


Thanks for that info. I've tried a couple of extra
things (below) and if I'm reading the output right I
thing you're correct about "items" returning a tuple,
and "values" returning the object. When I do the
repeat like this:

<tr tal:repeat="item context/items">
  <td tal:content="item">Name</td>
</tr>

The data presented look like this:

(u'Property', <lettings.property.Property object at
0x027ABEF0>)

However when I repeat over "values" instead of "items"
like this:

<tr tal:repeat="item context/values">
  <td tal:content="item">Name</td>
</tr>

... they change to this format:

<security proxied lettings.property.Property instance
at 0x027ABEF0>

So, it looks to me like values is returning the
contained item as single item, rather than a tuple of
it...

However, I still can't drag anything out of it. Having
changed the tal:repeat to "item context/values", I
have tried item/name, item/Name, item/getName,
item/title, item/Title... All return "NotFoundError".

I've googled, but am yet to find any Zope 3 specific
documentation for ZPT - could anyone point me in the
direction of some? (Or am I just doing something wrong
that wouldn't have worked in Zope 2 either?!?)

Thanks,
Jim

--- Tres Seaver <tseaver at palladion.com> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Jim Vine wrote:
> > Hello,
> > 
> > Re-reading this, I realised I'd not provided much
> > information on the "repeat" problem, so I'm
> filling in
> > some gaps.
> > 
> > This works as I would expect:
> > 
> > <table border="1" width="80%">
> >   <tr>
> >     <th>Number</th>
> >   </tr>
> >   <tr tal:repeat="item context/items">
> >     <td tal:content="repeat/item/number">#</td>
> >   </tr>
> > </table>
> > 
> > i.e., if it is repeating over a property folder
> with
> > four objects in it, it produces a table headed
> > "Number" and with 4 further rows with numbers 1,
> 2, 3,
> > and 4 in.
> > 
> > However, as soon as I add any meat to it, e.g.:
> > 
> > <table border="1" width="80%">
> >   <tr>
> >     <th>Number</th>
> >     <th>Name</th>
> >   </tr>
> >   <tr tal:repeat="item context/items">
> >     <td tal:content="repeat/item/number">#</td>
> >     <td tal:content="item/Name">Name</td>
> >   </tr>
> > </table>
> > 
> > I get an error which shows up on the error log as:
> > 
> > "TypeError: tuple indices must be integers"
> 
> Likely, 'context' is a dict, or a workalike, whose
> 'items' method
> returns a sequence of tuples.  Therefore, during the
> tal:repeat, 'item'
> is a tuple, (key, value).
> 
> Try using 'values' instead of 'items'.
> 
> 
> Tres.
> - --
>
===================================================================
> Tres Seaver          +1 202-558-7113         
> tseaver at palladion.com
> Palladion Software   "Excellence by Design"   
> http://palladion.com
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.5 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird -
> http://enigmail.mozdev.org
> 
>
iD8DBQFCynuh+gerLs4ltQ4RAl5uAKCRzRzV+g1M8gcbV07jSNfCQbWbhgCg0nL4
> 2POVN4oUQepYUIQ+pR1IPRU=
> =fBFx
> -----END PGP SIGNATURE-----
> 
> _______________________________________________
> Zope maillist  -  Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
> 



		
___________________________________________________________ 
How much free photo storage do you get? Store your holiday 
snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com


More information about the Zope mailing list