From 71f43c066973880cf03e1d7313e4ae7a22acbfd2 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Sun, 17 Jun 2012 23:36:35 -0500 Subject: [PATCH] fixed geocode, issue 855, thanks niphllod --- VERSION | 2 +- gluon/tools.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index a8f1928d..bffc564b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.00.0 (2012-06-17 23:35:00) dev +Version 2.00.0 (2012-06-17 23:36:32) dev diff --git a/gluon/tools.py b/gluon/tools.py index aa6549ff..b9cebe12 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -3567,13 +3567,12 @@ def fetch(url, data=None, headers=None, return html regex_geocode = \ - re.compile('\(?P[^,]*),(?P[^,]*).*?\') - + re.compile(r"""[\W]*?[\W]*?(?P[^<]*)[\W]*?(?P[^<]*)[\W]*?""") def geocode(address): try: a = urllib.quote(address) - txt = fetch('http://maps.google.com/maps/geo?q=%s&output=xml' + txt = fetch('http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=%s' % a) item = regex_geocode.search(txt) (la, lo) = (float(item.group('la')), float(item.group('lo')))