Folks-

(I guess this is sort of OT, so if anyone knows of the correct place
to post "HTTP Parameter Design best practice questions", feel free to
point me in the right direction)

Since I'm using pylons and people here tend to be smart and polite I'm
asking for feedback.

I'm need to send a datastructure around on the client and server sides
for my application.

A python tuple representation might look like this:

((key, (value1,value2,...)), (key2, (value3, ....)), (key3, (value4, ....)))

A dictionary-esque version might look like this:

dict( key=((value1,value2,...)),
  key2=((value3, ...)),
  key3=((value4, ...)))

Where key and value are semi arbitrary strings (should only be ascii)).

If I have a python object like above I can pass in this python object
to my template and create an analogous javascript version pretty
easily.  My question has to do with sending this data back in a form.

One way to do it is create a form parameter for each key and value.
Instead of using the key as the actual key, I could use some
predetermined naming scheme, so the parameters would be sent like this
(assuming the actual values are the names of the variables above for
simplicity sake, and assuming that "..." means no value):

K1=key1
V1=value1
V1=value2
K2=key2
V2=value3
K3=key3
V3=value4

Then when processing I can just iterate over all http parameters and
if the start with "K" followed by an int I assume they are part of
this dictionary, and then recreate my mapping on the server side.

Another way would be to try and create a long string and put some
psuedo-unique delimiters in the string ie:

MYDICT=key1||value1||value2,,key2||value3,,key3||value4

Neither of these solutions feels good to me.  But I think out of the
two I prefer the former (just to avoid the delimiter actually
occurring in the string, (probably wouldn't in practice)).

If anyone cares to share experiences/comments passing around similar
structures, I'm all ears.

thanks

matt

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to