POST request works in development, fails on Apache

7 views
Skip to first unread message

Ben G

unread,
Feb 21, 2010, 11:13:01 PM2/21/10
to geodjango
I'm having a problem with my geodjango app that I can't figure out.
I'm running django 1.1.1, apache 2.2, mod-wsgi 3.1

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

Daniel Hilton

unread,
Feb 22, 2010, 4:28:16 AM2/22/10
to geod...@googlegroups.com
On 22 February 2010 04:13, Ben G <ben...@gmail.com> wrote:
> I'm having a problem with my geodjango app that I can't figure out.
> I'm running django 1.1.1, apache 2.2, mod-wsgi 3.1
>
> 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.

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
============================

Ben G

unread,
Feb 23, 2010, 10:59:31 PM2/23/10
to geodjango
Dan, your comments sparked some thoughts for me. I'm going to try a
few more things especially regarding urllib. If I get some good
results, I'll post back the solution in case anyone else is struggling
with this too. Thank You,
Ben

On Feb 22, 1:28 am, Daniel Hilton <daniel.hil...@gmail.com> wrote:

Reply all
Reply to author
Forward
0 new messages