[Zope-dev] Re: Zope 2.7: OrderSupport for ObjectManager

Lennart Regebro lennart@regebro.nu
Wed, 07 May 2003 14:37:54 +0200


Yuppie wrote:
> This is the Interface we defined:
> <http://cvs.zope.org/Zope/lib/python/OFS/Attic/IOrderSupport.py?rev=1.1.2.2&content-type=text/vnd.viewcvs-markup> 

Right, more or less as expected. Although the moveObjectsUp and 
moveObjectsDown, moveObjectsToTop and moveObjectsToBottom is a bit 
redundant it doesn't hurt to have them there either.

> That's the way we did it.

Perfect.

All that is left if then the question if it should be implemented more 
as a 'mixin' than as a replacement for ObjectManager. Since, as far as I 
understand from the code, the ordered support is really done by a mixin 
class, and the OrderedFolder is just a Fodler+OrderSupport, this is 
really how it is done already, as a mixin, where you have a list that 
contain an order of Id's.

That means that the question of this being a replacement or a mixin is 
mostly a question of replacing the main.dtml or having a separate tab. 
As the code is now, OrderedFolder is using a replacement manage_main 
taken from OrderSupport. OrderSupport doesn't have a manage_main, so it 
will acquire it, but I assume this is just a temporary ommision, and 
that OrderSupport is supposed to have a specialized 'ordered_main.dtml'.
It would in that case be no problems in supplying a management tag that 
only supplies ordering too, of you need ordering mixin, but can't 
override manage_main.

The last question, as I understand it, is if the mixin should really be 
just a mixin where you not only order keys, but supply a storage for 
what should be ordered, so that the mixin has no ordering by itself, but 
instead order other sets. It would indeed be possible to do this, if 
these sets implement a standard ordering interface, for example the one 
above, or the simple ordering interface of being a list.

It can be done, and quite simply, by replacing the references to 
self._objects with a call to a method, like this one:

def getOrderStorage(self):
	return self._objects

You could then override this getOrderStorage() method with whatever you 
want in your object, and get it to point to whatever. In this case, the 
order storage must be a list.



Is this what you have been discussing, or have I misunderstood something?