RE: [Zope-dev] Order of Form Keys in REQUEST

2004-03-10 Thread Sandra Chong
Oops, sorry about that. It's hard to tell just by the descriptions on
Zope.org which is the best list for what.

Thanks for the other tip. :) I'll probably stick with holding a server-side
array with the info, though, as I might decide later to dynamically generate
the forms (there are a few) using the data held in there.

> -Original Message-
> From: Max M [mailto:[EMAIL PROTECTED]
> Sent: Thursday, 11 March 2004 9:05 AM
> To: Sandra Chong
> Cc: [EMAIL PROTECTED]
> Subject: Re: [Zope-dev] Order of Form Keys in REQUEST
>
>
> Sandra Chong wrote:
> > Thank you so much. :D You guys are legends. I will try keeping
> a separate
> > ordered list and save it in the session for the form handler to
> refer to.
> > Many thanks again. :)
>
>
> It is easier to save it in a hidden field in the form:
>
>  
>
> And then you can get it like (PythonScript):
>
>  sorted_keys = REQUEST['sorted_keys'].split(',')
>
> But as far as I remember, a form keps the order of items in it, per the
> spec. So you could probably do:
>
>  
>   tal:attributes="key">
>  
>
> Which you can get like (PythonScript):
>
>  sorted_keys = REQUEST['sorted_keys']
>
> And I am pretty shure that they are in order. But I could be wrong, so
> the first approach is probably the safest.
>
> Btw. These questions should really be asked on the Zope list, not
> zope-dev. zope-dev is for subjects regarding the development of zope,
> while the zope list is for development with Zope.
>
>
> regards Max M
>


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Order of Form Keys in REQUEST

2004-03-10 Thread Max M
Sandra Chong wrote:
Thank you so much. :D You guys are legends. I will try keeping a separate
ordered list and save it in the session for the form handler to refer to.
Many thanks again. :)


It is easier to save it in a hidden field in the form:



And then you can get it like (PythonScript):

sorted_keys = REQUEST['sorted_keys'].split(',')

But as far as I remember, a form keps the order of items in it, per the 
spec. So you could probably do:




Which you can get like (PythonScript):

sorted_keys = REQUEST['sorted_keys']

And I am pretty shure that they are in order. But I could be wrong, so 
the first approach is probably the safest.

Btw. These questions should really be asked on the Zope list, not 
zope-dev. zope-dev is for subjects regarding the development of zope, 
while the zope list is for development with Zope.

regards Max M

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


RE: [Zope-dev] Order of Form Keys in REQUEST

2004-03-10 Thread Sandra Chong
Thank you so much. :D You guys are legends. I will try keeping a separate
ordered list and save it in the session for the form handler to refer to.
Many thanks again. :)

Sandra.

> -Original Message-
> From: Chris Withers [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, 10 March 2004 11:19 PM
> To: Max M
> Cc: Sandra Chong; [EMAIL PROTECTED]
> Subject: Re: [Zope-dev] Order of Form Keys in REQUEST
>
>
> Max M wrote:
>
> > Dictionary keys are unordered.
> >
> > You need to store the order of the keys somewhere else. Ie. to have a
> > list in your form with the keys in order, Or to name them
> alphabetically
> > and then sort the keys.
>
> ...or just do something like:
>
> keys = REQUEST.form.keys()
> keys.sort()
> for key in keys:
>print key
>print REQUEST.form[key]
>
> return printed
>
> cheers,
>
> Chris
>
> --
> Simplistix - Content Management, Zope & Python Consulting
> - http://www.simplistix.co.uk
>
>


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Order of Form Keys in REQUEST

2004-03-10 Thread Chris Withers
Max M wrote:

Dictionary keys are unordered.

You need to store the order of the keys somewhere else. Ie. to have a 
list in your form with the keys in order, Or to name them alphabetically 
and then sort the keys.
...or just do something like:

keys = REQUEST.form.keys()
keys.sort()
for key in keys:
  print key
  print REQUEST.form[key]
return printed

cheers,

Chris

--
Simplistix - Content Management, Zope & Python Consulting
   - http://www.simplistix.co.uk
___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Order of Form Keys in REQUEST

2004-03-10 Thread Max M
Sandra Chong wrote:

> How does Zope's REQUEST object decide what order to store the form keys?
> I've got a form with fields in order a, b, c, d - but in REQUEST.form,
> they're stored out of order.
>
> This is causing quite a big problem, as I'd like to dynamically 
output the
> form values in order after the form has been submitted.

Dictionary keys are unordered.

You need to store the order of the keys somewhere else. Ie. to have a 
list in your form with the keys in order, Or to name them alphabetically 
and then sort the keys.

regards Max M

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )