[Zope] Order by property

Lars Heber Lars.Heber@t-systems.de
Fri, 09 Mar 2001 12:49:38 +0100


Andrew Fielden schrieb:

> Lars
>
> Thanks for that it has taken me part way as I can certainly now create an
> order for the items in the directory.
>
> Unfortunately if I try to change the code to
> <dtml-in objectValues sort=paraNum>
>    <dtml-var sequence-item><br>
> </dtml-in>
>
> The code breaks telling me that
> Zope has encountered an error while publishing this resource.
>
> Error Type: KeyError
> Error Value: para1.paraNum
>

Doesn't do that with my test... - it works!?!

Perhaps try <dtml-var "_['sequence-item']">

But now I've got an idea:

Through that construct _every_ doc / method in your folder is rendered!
So I think the error occurs in one of your docs / methods, but not in that
construct!

This can be quite confusing!

Also be aware that the method itself is rendered again - but for some (for me
quite unclear) reasons it doesn't render the construct recursively - I think
that is because the repeatedly rendered method doesn't have elements in
objectValues.

You can test that by inserting a line:
<dtml-in objectValues sort=myprop>
   <dtml-var "_['sequence-item']"><br>
<dtml-else>No elements in list to run through...<br>
</dtml-in>

It could also be the case that the error occurs in the method when rendered
again.
So just avoid to render "yourself" again:

<dtml-in objectValues sort=myprop>
   <dtml-unless "_['document_id']  == _['id']">
      <dtml-var sequence-item><p><br></p>
   </dtml-unless>
<dtml-else>No elements in list to run through...<br>
</dtml-in>

Note to use the long winded _['...'] thing for getting a string instead of just
"document_id == id" which are methods or somewhat... Don't know exactly.

--
Lars Heber, mailto:Lars.Heber@t-systems.de          TTTTTT
                                                      TT
T-Systems, debis Systemhaus GEI GmbH              O   TT   O   O   O
                                                      TT