[Zope-dev] ZPatterns design questions

Steve Spicklemire steve@spvi.com
Fri, 6 Oct 2000 06:16:55 -0500 (EST)


I should point out a couple of things that might not be
obvious (that I noticed only on a second 'read' of the explaination):

1) getPersistentItemIds() can be a pain.

<dtml-in "defaultRack.getPersistentItemIDs()" sort>

is straightforward enough... but what if I don't care if they are
sorted, or I want to sort on some other property? One would
think that you could do something like...:

<dtml-let foo="[]">
<dtml-in "defaultRack.getPersistentItemIDs()">
<dtml-call "foo.append(defaultRack.getItem(_['sequence-item']))">
</dtml-in>

<dtml-in foo sort=description>
...
</dtml-in>
</dtml-let>

But it doesn't work! You get 'Authorization Failed'. There was a bit of email
on the list when I found this problem.... but it doesn't seem to bother
anyone too much.... it turns out that getPersistentItemIds() actually
returns a BTree object, which is not covered by the Zope security system
as an allowed 'simple' subobject. However, when you 'sort' the list
in the 'in' tag.. a side effect is that it it copied to a plain old
Zope list..... so it's OK. ;-) So... you *can* do 

<dtml-let foo="[]">
<dtml-in "defaultRack.getPersistentItemIDs()" sort>
<dtml-call "foo.append(defaultRack.getItem(_['sequence-item']))">
</dtml-in>

<dtml-in foo sort=description>
...
</dtml-in>
</dtml-let>

Soo.. the moral of that story is... if you're not allowed to see 
something... just sort it! :-) !! ;-(

2) This simple/dumb example using a Specialist/Rack combination. There is another
approach (that Steve Alexander has used a lot I gather) which is to use the
Folder with customizer support. I've never tried that since I went down this
road and wanted to sort it out before 'branching' to other methods. To be
fair I should probably try to implement this same example with that approach.

-steve