[Zope] Order by property

Andrew Fielden andrew.fielden@emotion.co.uk
Fri, 9 Mar 2001 13:42:56 -0000


Lars

I now have it working - using all of the methods (including the simple one
that didn't work for my directory). I have looked and looked at the original
but cannot see how it is different!

Anyhow thank you again for your help.

Andrew

-----Original Message-----
From: Lars Heber [mailto:Lars.Heber@t-systems.de]
Sent: 09 March 2001 11:50
To: andrew.fielden@emotion.co.uk
Cc: zope@zope.org
Subject: Re: [Zope] Order by property


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