J.. Posted July 15, 2009 Posted July 15, 2009 I've followed the instructions here, but I just see the dispatch.wsgi file's source code, even though its permissions are set to 755. The project is just something simple to see if I could get it to work, and it runs fine locally. Have I done something wrong?
J.. Posted July 16, 2009 Author Posted July 16, 2009 Okay, sorry to bother you again, but urllib2.urlopen doesn't seem to be working in Django. If I put the following script in cgi-bin: #!/usr/bin/python print "Content-type:text/html\n" from urllib2 import urlopen, URLError out = "" try: urlopen("http://google.com") except URLError, e: print "<p>"+str(e.reason)+"</p>" print "<p>done</p>" The output is '<p>done</p>'. But if I use this in Django (views.py): from django.shortcuts import HttpResponse from urllib2 import urlopen, URLError def sample (request): out = "" try: urlopen("http://google.com") except URLError, e: out += "<p>"+str(e.reason)+"</p>" out += "<p>done</p>" return HttpResponse(out) The output is '<p>unable to select on socket</p><p>done</p>'. Is there any reason this might be happening? These are located here and here respectively
Ashoat Posted July 16, 2009 Posted July 16, 2009 Unfortunately, I barely know any Python. Here's what I can tell you: when you access Python through the cgi-bin method, it loads as CGI through Apache's mod_cgi. On the other hand, when you access Python through the Django method, it loads as WSGI through Apache's mod_wsgi. We only have one version of Python installed, but perhaps different Python eggs are preloaded for each system. Perhaps you should try manually added a Python egg for urlopen in your Django app? Also, try installing SnakeCharmer (looks like this) to check if urlopen is installed. I would probably try to direct this question at a Python-specific forum. If they tell you that your host is at fault, make sure to ask them exactly what I need to do to fix the problem and I'll do my best to help.
J.. Posted July 16, 2009 Author Posted July 16, 2009 It's definitely there, it's just not working right through Django. Thanks anyway; I'll see what I can find out. Wait, what do you mean, 'try installing SnakeCharmer'? What is it, and why would it help?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now