I got my app ready using the development server (manage.py
runserver). Everything works perfectly, no errors and no failures.
I've run it on a windows machine and a linux machine and it's flawless
on both. It works under Firefox, Chrome, and Explorer (a few
formatting problems under explorer)
Then I deployed it on Apache. Everything works, except one feature.
I have a geocoding function that is triggered by clicking a button and
selecting a property from a drop down list. The address for the
property is sent to google geocoder, and the response is parsed into a
boundbox and the map zooms to the extent (or at least it SHOULD).
Under Apache the response comes back empty and nothing happens. I
have tried it under apache 2.2 on a Linux box, a windows box, and I've
deployed it on webfaction- same result everywhere.
Runserver works, apache doesn't.
The request is sent to google using a POST request. I have another
POST request in my app that allows users to add a feature to the map;
the other POST works fine on both production and development servers.
I"m getting no errors in the apache error log, none in firebug, no
django errors.
Here is the code from views.py for that function:
def lookup(request):
output_format='json'
if request.method == 'POST':
location = request.POST.get('address')
location = urllib.quote_plus(location)
geocode = "http://maps.google.com/maps/geo?q=%s&output=%s&key=
%s" % (location, output_format, settings.GMAPS_API_KEY)
data = urllib.urlopen(geocode).read()
json = eval(data)
if json.get('Status').get('code') == 200:
bbox = json['Placemark'][0]['ExtendedData']['LatLonBox']
n,s,e,w =
bbox['north'],bbox['south'],bbox['east'],bbox['west']
sw,ne = Point(w,s),Point(e,n)
e = sw.union(ne).envelope.extent
bounds = dict(a=e[0], b=e[1], c=e[2], d=e[3])
response = HttpResponse()
response.write(bounds)
response['Content-Type'] = "text/json"
response['Content-Length'] = len(bounds)
return response
return HttpResponseBadRequest()
Any ideas?
Thanks,
Ben
This sounds like a non geodjango error, in that the different servers
are the issue.
Are you running the same environment when you use the devserver and
the mod_wsgi setup?
Could it be pulling in a different version of the urllib? Are you
using a virtualenv?
Can you just hit the google api ok? Can you use urllib to pull a
webpage and just include the source?
Cheers,
Dan
--
Dan Hilton
============================
www.twitter.com/danhilton
www.DanHilton.co.uk
============================
On Feb 22, 1:28 am, Daniel Hilton <daniel.hil...@gmail.com> wrote: