On Tue, Jan 19, 2010 at 09:52:58AM +0530, Anand Chitipothu wrote:
> On Tue, Jan 19, 2010 at 1:16 AM, Pablo Antonio <[email protected]> wrote:
[snip]
> >
> > What about including something like this in the framework? Would that
> > against web.py's "keep it simple" philosophy?
>
> That can possibly go to utils.py.
Ok.
> Will it be better to support "data[1][age]" format instead of "data--1--age"?
I don't know. The first one is what PHP uses and it seems[1] it's what
Ruby on Rails uses too. The second is a format you invented, if I'm not
mistaken.
Anyway, any of them is OK to me.
One thing that I don't like about your implementation is that, if I
recall correctly, you see if every element in a level of the "array" is
an integer and, if that is the case, you make that level be a
list. What I don't like about this is that sometimes you want your
indices to start from something different than 0.
For example, imagine I have an input whose name is "data--1--age". Then,
I'd like to access its data as i["data"][1]["age"]. However, look what's
unflatten's result:
>>> unflatten({"data--1--age": "20"})
<Storage {'data': [<Storage {'age': '20'}>]}>
This is what I have to do to get that "20":
>>> i = unflatten({"data--1--age": "20"})
>>> i["data"][0]["age"]
'20'
Maybe the simplest solution to this problem is just return the
dictionary without ever calling makelist(). However, there must be a
reason why you wrote that function, and I'd like to know it :)
Thanks,
[1]
http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html
--
Pablo Antonio (AKA crazy2k)
http://www.pablo-a.com.ar/
--
You received this message because you are subscribed to the Google Groups
"web.py" 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/webpy?hl=en.