I receive this dict that Denes helped me with:
{u'postalcodes': [{u'placeName': u'Novato', u'countryCode': u'US', u'lat':
38.061837, u'postalcode': u'94949', u'lng': -122.540408, u'adminName2':
u'Marin', u'adminCode1': u'CA', u'adminCode2': u'041', u'adminName1':
u'California'}, {u'placeName': u'Cr\xe9teil', u'countryCode': u'FR',
u'adminName3': u'Arrondissement de Cr\xe9teil', u'lat': 48.7833333,
u'postalcode': u'94949 CEDEX 9', u'lng': 2.4666667, u'adminName1':
u'\xcele-de-France', u'adminName2': u'Val-de-Marne', u'adminCode1': u'A8',
u'adminCode2': u'94', u'adminCode3': u'941'}]}
User chooses one of the countries.
But for some reason I cannot get the chosen field values transferred to the
next function:
I use this to capture the field values and send them to next function:
{{cc=[]}}
{{for x in location_data_from_postal_code['postalcodes']:}}
{{cc.append(x['countryCode'])}}
{{c=x['countryCode']}}
{{adminCode1=x['adminCode1']}}
{{adminName1=x['adminName1']}}
{{if c not in cc:}} <!-- chooses only unique country -->
{{countryName=db(db.Country.countryCode==c).select(limitby=(0,1)).first()}}
<h3>{{=A(countryName.countryName,
_href=URL('default','verify_correct_location', vars=dict(countryCode=c,
adminCode1=adminCode1, adminName1=adminName1)))}}</h3>
{{pass}}
{{pass}}
In the "IF" line, the values of adminCode1 cause this error:
<type 'exceptions.UnicodeEncodeError'> 'ascii' codec can't encode character
u'\xce' in position 0: ordinal not in range(128)
But the countryCode=c works.
Anyone see a better way to write the code so that the dictionary values can
be transferred to the next function?
thanks
Alex Glaros
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.