[Zope] sorting ids in python

Andreas Jung lists at zopyx.com
Tue Dec 9 04:51:08 EST 2008


On 09.12.2008 8:45 Uhr, Garry Saddington wrote:
> On Tuesday 09 December 2008 03:15, Andreas Jung wrote:
>> On 08.12.2008 21:11 Uhr, robert rottermann wrote:
>>> Garry Saddington schrieb:
>>>> Can anyone help me sort the following by id in a python script?
>>>>
>>>> for object in context.objectValues(['Folder', 'DTML
>>>> Document','ZipFolder','File','Image']):
>>> objs=context.objectValues(['Folder',
>>> 'DTMLDocument','ZipFolder','File','Image']) objs.sort()
>>> for o in objs:
>>>    ..
>> huh? Afaik there is no sort order defined on a per-object basis.
>>
> This is my final working solution:
>
> ids = context.objectIds(['Folder', 'DTMLDocument','ZipFolder','File','Image'])
> ids.sort()
> for object in ids:
>      object=context.restrictedTraverse(object)
>      path=object.absolute_url()
> ...........................


You were asking about IDs in the first place, so use objectIds().
If you are interested in the object themselves, use objectItems() as RR
suggested.

-aj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lists.vcf
Type: text/x-vcard
Size: 316 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope/attachments/20081209/1546357e/attachment.vcf 


More information about the Zope mailing list