Default sort order for objects in objectManagers ??
What decides the default sort order for the values returned when I do a "objectIds()" etc? I cannot find it on either Google or in the source. It seems that it's sorted in creation order. Is that correct and guaranteed? regards Max M
There is no predefined order. Use check the documentation for dtml-in how to sort inside <dtml-in> or use the _.sequence.sort() to sort the sequence of objects. -aj ----- Original Message ----- From: "Max M" <maxm@mxm.dk> To: <zope@zope.org> Sent: Tuesday, May 07, 2002 08:33 Subject: [Zope] Default sort order for objects in objectManagers ??
What decides the default sort order for the values returned when I do a "objectIds()" etc?
I cannot find it on either Google or in the source.
It seems that it's sorted in creation order. Is that correct and guaranteed?
regards Max M
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On Tue, 07 May 2002 14:33:27 +0200, Max M <maxm@mxm.dk> wrote:
What decides the default sort order for the values returned when I do a "objectIds()" etc?
I cannot find it on either Google or in the source.
It seems that it's sorted in creation order.
Order in which they were added to the folder, which is almost the same thing.
Is that correct and guaranteed?
No. It is possible that there will be an API for changing the order added to ObjectManager in Zope 2.6 Toby Dickenson tdickenson@geminidataloggers.com
Max M wrote:
What decides the default sort order for the values returned when I do a "objectIds()" etc?
I cannot find it on either Google or in the source.
It seems that it's sorted in creation order. Is that correct and guaranteed?
regards Max M
Use the source, Luke ! sorry, just scrutuinized Folder (i recommend richters OrderedFolder, download from iuveno) The items (in ObjectManager) are added with setattr, which is an insert into the ObjManagers object dictionary and relies deeply on the hashing built into python dictionaries. item retrieval = getattr. This essentially makes retrieval order close to unpredictable. It has been suggested that zope 2.6 should have orderedFolders built in. (i personally would like to have a python ordered_dictionary :-) ) -- ------------------------------------------------------------- Who's got only a hammer sees the world as a nail hans augustin (software developer) hans@beehive.de beehive elektronische medien GmbH http://www.beehive.de phone: +49 30 847-82 0 fax: +49 30 847-82 299
On Tue, 07 May 2002 14:57:41 +0100, hans <hans@beehive.de> wrote:
Use the source, Luke !
Youve just proved that is not always good advice ;-)
sorry, just scrutuinized Folder (i recommend richters OrderedFolder, download from iuveno) The items (in ObjectManager) are added with setattr, which is an insert into the ObjManagers object dictionary and relies deeply on the hashing built into python dictionaries. item retrieval = getattr. This essentially makes retrieval order close to unpredictable.
It also maintains _objects, a tuple. It uses this order, not anything derived from __dict__, when computing objectIds etc.
It has been suggested that zope 2.6 should have orderedFolders built in. (i personally would like to have a python ordered_dictionary :-) )
a BTree? Toby Dickenson tdickenson@geminidataloggers.com
Toby Dickenson wrote:
On Tue, 07 May 2002 14:57:41 +0100, hans <hans@beehive.de> wrote:
Use the source, Luke !
Youve just proved that is not always good advice ;-)
very, very, sorry. YOU are right.
sorry, just scrutuinized Folder (i recommend richters OrderedFolder, download from iuveno) The items (in ObjectManager) are added with setattr, which is an insert into the ObjManagers object dictionary and relies deeply on the hashing built into python dictionaries. item retrieval = getattr. This essentially makes retrieval order close to unpredictable.
It also maintains _objects, a tuple. It uses this order, not anything derived from __dict__, when computing objectIds etc.
It has been suggested that zope 2.6 should have orderedFolders built in. (i personally would like to have a python ordered_dictionary :-) )
a BTree?
no, something like OrderedFolder mostly to fix arbitrary ordering. a lot of navigation/sitemap tools would be obsoleted or simplified by that -- ------------------------------------------------------------- Who's got only a hammer sees the world as a nail hans augustin (software developer) hans@beehive.de beehive elektronische medien GmbH http://www.beehive.de phone: +49 30 847-82 0 fax: +49 30 847-82 299
hans wrote:
Max M wrote:
The items (in ObjectManager) are added with setattr, which is an insert into the ObjManagers object dictionary and relies deeply on the hashing built into python dictionaries. item retrieval = getattr. This essentially makes retrieval order close to unpredictable.
Yes if if the object dictionary is indeed an ordinary dict. But I have a sneaking suspicion that it is a Btree of sorts, and so the rules can be different. And the behaviour suggets that it is so. Try and create some objects in a folder and then view the objectIds(). They are allways ordered in the order they are created. regards Max M
participants (4)
-
Andreas Jung -
hans -
Max M -
Toby Dickenson