You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web2py-users
Hi,
I have a variable r = request.post_vars of the form { 'a':1, 'b':2, 'ab': { 'aba':10 , 'abb':20 } }
it's a gluon.storage.Storage object. how do I extract r['ab'] ?
this doesn't work : r.pop('ab',None) , r.ab , r['ab']['aba'] , r.ab.aba
Anthony
unread,
May 19, 2016, 11:08:51 AM5/19/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web2py-users
Are you sure you have the structure correct? How is it populated, and what do you get when you print it?
Pierre
unread,
May 19, 2016, 11:52:50 AM5/19/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web2py-users
here is the view output displaying the object
r
:
address
:
17 Rue Farges, 13008 Marseille, France
admlev_one
:
Provence-Alpes-Côte d'Azur
admlev_two
:
Bouches-du-Rhône
country
:
FR
latlon[lat]
:
43.2806116
latlon[lon]
:
5.384511599999996
locality
:
Marseille
postalcode
:
13008
t
:
<class 'gluon.storage.Storage'>
it's well parsed 'latlon' is nested as 'ab' in the example above how do I print it /where ?
Anthony
unread,
May 19, 2016, 1:06:28 PM5/19/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web2py-users
Looks like maybe whatever process generates the post request is representing a nested data structure via brackets -- so the key "latlon[lat]" is meant to represent an object like {'latlon': {'lat': the_value}}. However, web2py doesn't know to parse keys containing brackets into a nested data structure, so it just takes the key as is. You can probably access the relevant value via request.post_vars['latlon[lat]'].
Anthony
Pierre
unread,
May 19, 2016, 1:54:22 PM5/19/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web2py-users
ok I'll flatten the object and I expect it's not going to complain.........