[Zope] What If i don't want Zope sorting for me.

Chris Withers chrisw@nipltd.com
Mon, 25 Feb 2002 15:01:21 +0000


> Terry wrote:
> 
> I have a dictionary in REQUEST.
> 
> <dtml-call "REQUEST.set('my_dic',{'ar_id':'Article
> ID','ar_head':'Head','ar_body':'Body'})">
> <dtml-var "my_dic.keys()">
> 
> Zope will sort for me. How to use the original order ?

1. Don't use DTML for that kindof code, it's nasty. Use a Script (Python)
instead.

the above would be:

context.REQUEST.set('my_dict',
                    {
                      'ar_id'  :'Aticle ID',
                      'ar_head':'Head',
                      'ar_body':'Body'})
return REQUEST.my_dict.keys()

As for the sorting, Zope sorts nothing. Python Dictionaries don't promise to
order their keys so you may get them back in any random order.

cheers,

Chris

PS: HTML to a non-HTML list is also a no-no. Stop usign Outlook Express before
it kills you ;-)