[Zope] Referencing Objects from id's stored in a lines property. -- Yet Another Update
Tom Jenkins
tjenkins@devis.com
Thu, 16 Aug 2001 20:48:03 -0400
Hey Ron,
complaw@hal-pc.org wrote:
> I'm considering using a DTML document having a lines property that stores
> id's of related objects (i.e., objects where there is to be a user-defined
> relation). Essentially, the lines property would be a container of id's of
> objects available to the object having the lines container.
>
> I can load the id's into the lines property (that is easy). However, does
> anyone know of the DTML code needed to sequentially list each of the elements
> in the lines property (which is a Python list) and then call that object to
> obtain and then display the title corresponding to the object id?
>
> The following code works...
>
> <P>Here they are, one by one.<BR>
> <dtml-in cases>
> <A HREF="<dtml-var sequence-item>"><dtml-var sequence-item></A><BR>
> </dtml-in>
>
> But the above code only lists the id's, not the titles to the id's (which
> would be easier for the user to understand).
>
Ok you're close.
<dtml-in cases>
<A HREF="<dtml-var sequence-item>"><dtml-var
expr="_.getitem(_['sequence-item']).title"></A><BR>
</dtml-in>
The key is that the sequence-item has the id as a string, so you need to
get the item that the id refers to out of the _ namespace.
Actually this code is a little nastier than it needs to be because of a
(soon-to-be-fixed?) problem with name "sequence-item". The following
code also works
<dtml-in cases>
<dtml-let sequence_item="_['sequence-item']">
<A HREF="<dtml-var sequence_item>"><dtml-var
expr="_.getitem(sequence_item).title"></A><BR>
</dtml-let>
</dtml-in>
the embedded '-' in sequence-item means we have to use the
_['sequence-item'] whenever we drop down into expression.
hope that helps
--
Tom Jenkins
devIS - Development Infostructure
http://www.devis.com