On Jan 4, 9:25 pm, Patrick May <[email protected]> wrote:
> Hi,
>
> I have Django running under Apache with mod_wsgi.  I've got a simple URL 
> handler that looks like this:
>
> def handler(request):
>     response = None
>
>     if request.method == 'POST' or request.method == 'PUT':
>         response = HTTPResponse(status=201)
>     elif request.method == 'GET':
>         response = HttpResponse("Success")
>     else:
>         raise Http404
>
>     return response
>
> My django.wsgi looks like this:
>
> import os
> import sys
>
> sys.path.append('/Users/Patrick/codestreet/src/rest')
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'server.settings'
>
> import django.core.handlers.wsgi
>
> application = django.core.handlers.wsgi.WSGIHandler()
>
> When I connect to the URL for the handler with a GET like this:
>
>         request = urllib2.Request(self.URL)
>
> it works fine, returning a 200.  However, when I connect with a POST like 
> this:
>
>         request = urllib2.Request(self.URL,self.data)
>
> I get an exception thrown with a 500 code and this in the Apache error log:
>
> [Mon Jan 04 16:20:08 2010] [error] [client ::1] mod_wsgi (pid=48698): 
> Exception occurred processing WSGI script 
> '/Users/Patrick/codestreet/src/rest/django.wsgi'.
> [Mon Jan 04 16:20:08 2010] [error] [client ::1] IOError: failed to write data
>
> Do I have something misconfigured?
>
> Thanks,
>
> Patrick

Assuming the code you've posted is a real cut and paste, you have
"HTTPResponse" for POST but "HttpResponse" for GET. Python is case-
sensitive, so only "HttpResponse" will work.
--
DR.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to