DarwinSalaz / django-profile

Automatically exported from code.google.com/p/django-profile
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Exception thrown to view when http://ws.geonames.org/ is down. #77

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
sometimes http://ws.geonames.org/ is down so the django-profile's view
throws an exception

What is the expected output? What do you see instead?
Not throwing an 

What version of the product are you using? On what operating system?
r430 with django 1.1.1

Please provide any additional information below.
-

I would wrap @ line 82 on the views (userprofile/views.py) the
urllib.urlopen call inside a try catch block and send the user a
customizable message or disable this functionality gracefully.

For instance some solution could be:
83,87c83
<         try:
<             country = dom.getElementsByTagName('countryCode')
<         except IOError:
<             return Http404() #or an empty response maybe like
<             #return HttpResponse(simplejson.dumps({'success': False,
'country': None, 'region': None}))

---
>         country = dom.getElementsByTagName('countryCode')

This isn't actually problematic but sometimes when the
http://ws.geonames.org/ doesn't respond a highly crowded webserver can fill
his logs easily.

Original issue reported on code.google.com by korka...@gmail.com on 26 Mar 2010 at 12:58

GoogleCodeExporter commented 8 years ago
I've got the same issue on my website.
I've very small amount of unique visitors (about 500 a month) but still, I 
received this error more than 20 times in 6 months.
I wrote a script (attached) to benchmark few reverse geo-coding services 
ws.geonames.org included.

See an output example here (in that case I got 5 time outs for ws.geonames.org 
in 5 tests).

Average time results (in seconds):
{'maps.google.com': 0.26835980415344241,
 'where.yahooapis.com': 0.22819957733154297,
 'ws.geonames.org': 2}
Time out results :
{'maps.google.com': 0, 'where.yahooapis.com': 0, 'ws.geonames.org': 5}

Original comment by andre.mi...@gmail.com on 27 Aug 2010 at 3:24

Attachments:

GoogleCodeExporter commented 8 years ago
Hi,
I have overridden userprofile.views.fetch_geodata to use the Google Geocoding 
API.
http://pastebin.com/W5riKRmC
Also I found that the results were more accurate for Ireland.
I push it on the live server, see how it goes.

A patch would be very straight forward, except that I used xml.xpath which I 
thought was shipped Python 2.6 but it's actually part of PyXML, the extended 
XML support for Python.

Original comment by andre.mi...@gmail.com on 28 Aug 2010 at 10:27