On Jan 25, 12:54 pm, Mark Underwood <underpl...@gmail.com> wrote: > Hi all, > > Ive already posted a lot of information > herehttp://serverfault.com/questions/103480/http-500-error-from-post-reuq... > all the logs etc. so i figure i wont post it all again. But its come > down to ive got a view that takes a POST request, with a username and > password and validates it and if correct sends a http 200 back. This > works in the test server but when i deploy it using apache2, mod_wsgi > on ubuntu 9.10 and ubuntu 8.04 it returns a http 500 error. The django > debug page is posted below.Environment: > > Request Method: POST > Request > URL:http://bertha.homeunix.org:3000/radiobusi/auth/post_authentication_api > Django Version: 1.1.1 > Python Version: 2.6.4 > Installed Applications: > ['django.contrib.auth', > 'django.contrib.contenttypes', > 'django.contrib.sessions', > 'django.contrib.sites', > 'django.contrib.admin', > 'django.contrib.flatpages', > 'mysite.polls', > 'mysite.RadioBusi', > 'mysite.Support', > 'mysite.users'] > Installed Middleware: > ('django.middleware.common.CommonMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware', > 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware') > > Traceback: > File "/usr/local/lib/python2.6/dist-packages/Django-1.1.1-py2.6.egg/ > django/core/handlers/base.py" in get_response > 92. response = callback(request, *callback_args, > **callback_kwargs) > > Exception Type: TypeError at /auth/post_authentication_api > Exception Value: post_authentication_api() takes exactly 2 arguments > (1 given) > > my code is > > def post_authentication_api(self, request):
This doesn't match what you posted on ServerFault. When you posted there you had: def post_authentication_api(request): If you really do have a 'self' first argument for a function which isn't a method of a class, it is obvious you are going to get: Exception Type: TypeError at /auth/post_authentication_api Exception Value: post_authentication_api() takes exactly 2 arguments (1 given) as you indicated on ServerFault. Have you tried dropping the 'self' argument? Graham > if request.method == 'POST': > print request > user = authenticate(username=request.POST['user'], > password=request.POST['pass']) > if user is not None: > if user.is_active: > print "correct" > return HttpResponse("correct", mimetype="text/plain") > else: > print "disabled" > return HttpResponse("disabled", mimetype="text/plain", > status=401) > else: > print "incorrect" > return HttpResponse("incorrect", mimetype="text/plain", > status=401) > > So im not really sure what im doing wrong. My test code is > > url = 'http://testserver.com/auth/post_authentication_api' > values = {'user' : 'e_username', > 'pass' : 'e_password',} > > data = urllib.urlencode(values) > req = Request(url, data) > print req.get_full_url() > try: > response = urlopen(req) > except URLError, e: > print e.code > print e.read() > exit() > > the_page = response.read() > print the_page > > the thing that is puzzling me (apart form how to fix it) is that the > test server (ie manage.py runserver) works fine, but as soon as i > deploy it it comes back with this error. > > Any help would be great. And if more information is needed just let me > know. > > Cheers > > Mark -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.