Re: 'NoneType' object is not iterable
Hi Malcolm, Thank you very much for the detailed answer! Everything is working OK now. ///Kalle On May 8, 11:53 pm, Malcolm Tredinnickwrote: > On Fri, 2009-05-08 at 11:24 -0700,Kallewrote: > > Hi, > > > I'm just started to play with Django, and ran into this problem right > > away. > > > * I'm using the python script at the bottom to POST to the url. > > * I'm using "manage.py runserver" to run my app > > * Everything works fine when I'll run my tests with "manage.py test". > > > When I set a breakpoint at django/core/handlers/base.py:77 I see that > > request.path_info is "http://127.0.0.1:8000/uncaughtexception/drop;. > > From what I > > understand, request.path_info should be "/uncaughtexception/drop" at > > that point? > > > Since the tests works it must be some error in my setup of runserver. > > I can't understand what kind of setting I should use to make django > > strip way the host > > part of the URL. > > [...] > > > --- test script --- > > HOST = "127.0.0.1:8000" > > URL = "http://%s/uncaughtexception/drop; % HOST > > > h = httplib.HTTPConnection(HOST) > > headers = { "Content-Type" : "text/html; charset=utf-8" } > > h.request("POST", URL, "apa", headers) > > This is where the problem lies. The URL you send to the host should not > contain the hostname and scheme. That is already implicit in the > HTTPConnection object. So your URL variable should be simply > "/uncaughtexception/drop/". > > A rough breakdown of what happens when your webbrowser (or anything > speaking HTTP) connects tohttp://example.com/foo/bar/is this: > > (1) Connection opened to example.com, port 80 > (2) Down that connection, the client sends > > GET /foo/bar HTTP/1.1 > Host example.com > ... > > (the "..." hides some extra headers that might be sent) > > Notice that the "GET" request includes the resource to retrieve. It > already knows *where* to send it because it's made a network connection. > In your case, GET becomes POST and there's a different port number > involved, etc, but the point is that single URL encapsulates multiple > operations. > > Now, all this being said, you're potentially making life a little hard > for yourself here if you're only wanting to test your views. Django > contains a little test client that simulates a browser connection, > without requiring you to run a whole separate server and so on. What > you're doing isn't necessarily wrong, but if you're unaware > ofhttp://docs.djangoproject.com/en/dev/topics/testing/#module-django.te...you > might want to have a quick play with that first. It will make your tests a > fair bit simpler. > > Regards, > Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~--~~~~--~~--~--~---
Re: 'NoneType' object is not iterable
On Fri, 2009-05-08 at 11:24 -0700, Kalle wrote: > Hi, > > I'm just started to play with Django, and ran into this problem right > away. > > * I'm using the python script at the bottom to POST to the url. > * I'm using "manage.py runserver" to run my app > * Everything works fine when I'll run my tests with "manage.py test". > > When I set a breakpoint at django/core/handlers/base.py:77 I see that > request.path_info is "http://127.0.0.1:8000/uncaughtexception/drop;. > From what I > understand, request.path_info should be "/uncaughtexception/drop" at > that point? > > Since the tests works it must be some error in my setup of runserver. > I can't understand what kind of setting I should use to make django > strip way the host > part of the URL. [...] > --- test script --- > HOST = "127.0.0.1:8000" > URL = "http://%s/uncaughtexception/drop; % HOST > > h = httplib.HTTPConnection(HOST) > headers = { "Content-Type" : "text/html; charset=utf-8" } > h.request("POST", URL, "apa", headers) This is where the problem lies. The URL you send to the host should not contain the hostname and scheme. That is already implicit in the HTTPConnection object. So your URL variable should be simply "/uncaughtexception/drop/". A rough breakdown of what happens when your webbrowser (or anything speaking HTTP) connects to http://example.com/foo/bar/ is this: (1) Connection opened to example.com, port 80 (2) Down that connection, the client sends GET /foo/bar HTTP/1.1 Host example.com ... (the "..." hides some extra headers that might be sent) Notice that the "GET" request includes the resource to retrieve. It already knows *where* to send it because it's made a network connection. In your case, GET becomes POST and there's a different port number involved, etc, but the point is that single URL encapsulates multiple operations. Now, all this being said, you're potentially making life a little hard for yourself here if you're only wanting to test your views. Django contains a little test client that simulates a browser connection, without requiring you to run a whole separate server and so on. What you're doing isn't necessarily wrong, but if you're unaware of http://docs.djangoproject.com/en/dev/topics/testing/#module-django.test.client you might want to have a quick play with that first. It will make your tests a fair bit simpler. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~--~~~~--~~--~--~---
Re: 'NoneType' object is not iterable
It works!! Thank you very much!! The django.root PythonOption stripped the initial "/" Greetings. On Nov 11, 11:54 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > Hi Javi, > > > I've tried putting FORCE_SCRIPT_NAME="" but everything continues at > > the same state. I'm running the app in Apache2/mod_python. I've pasted > > the htttp.conf file athttp://rafb.net/p/Ya1VKT55.html > > I can't see your conf file there. Perhaps you want to paste again > athttp://dpaste.com/? > > Take a look at the django.root PythonOption described here: > > http://docs.djangoproject.com/en/dev/howto/deployment/modpython/?from... > > Are you using that option? If, yes, remove that option entirely and > try again. > > -Rajesh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: 'NoneType' object is not iterable
Hi Javi, > I've tried putting FORCE_SCRIPT_NAME="" but everything continues at > the same state. I'm running the app in Apache2/mod_python. I've pasted > the htttp.conf file athttp://rafb.net/p/Ya1VKT55.html I can't see your conf file there. Perhaps you want to paste again at http://dpaste.com/ ? Take a look at the django.root PythonOption described here: http://docs.djangoproject.com/en/dev/howto/deployment/modpython/?from=olddocs#basic-configuration Are you using that option? If, yes, remove that option entirely and try again. -Rajesh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: 'NoneType' object is not iterable
Same problem. Any suggestions? I am using nginx with fapws2 (wsgi server). Looks like script kiddie thinks that my web server is an open proxy (88.80.7.248 is NOT my IP address): Traceback (most recent call last): File "/usr/local/lib/python2.5/site-packages/django/core/handlers/ base.py", line 77, in get_response request.path_info) TypeError: 'NoneType' object is not iterable , POST:, COOKIES:{}, META:{'HTTP_ACCEPT': '*/*', 'HTTP_HOST': '88.80.7.248', 'HTTP_PRAGMA': 'no-cache', 'HTTP_PROXY_CONNECTION': 'Keep-Alive', 'PATH_INFO': u'http://88.80.7.248/proxy-pool/set-cookie.php', 'QUERY_STRING': '', 'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': u'', 'SERVER_NAME': '127.0.0.1', 'SERVER_PORT': 8080, 'fapws.http_major': 1, 'fapws.http_minor': 1, 'fapws.params': {}, 'fapws.remote_host': '88.80.7.248', 'fapws.remote_port': 34609, 'fapws.uri': 'http://88.80.7.248/proxy-pool/set-cookie.php', 'wsgi.errors': , 'wsgi.input': , 'wsgi.multiprocess': True, 'wsgi.multithread': False, 'wsgi.run_once': False, 'wsgi.url_scheme': 'http', 'wsgi.version': (1, 0)}> --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: 'NoneType' object is not iterable
Hi Javi, I'm having the same problem... any progress so far? Thanks. On Nov 10, 8:35 am, Javi <[EMAIL PROTECTED]> wrote: > Hello Rajesh, > > I've tried putting FORCE_SCRIPT_NAME="" but everything continues at > the same state. I'm running the app in Apache2/mod_python. I've pasted > the htttp.conf file athttp://rafb.net/p/Ya1VKT55.html > > I'm going to continue trying to solve it. > > On Nov 5, 7:11 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > > > Hi Javi, > > > > Thanks but I'd already tried it. I don't understand why in the > > > production server is not added the preceeding slash to the url. My > > > urls.py is as follows: > > > urlpatterns = patterns('candidateTool.assessmentSystem.views', > > > (r'^$', 'index'), > > > (r'^enter/$', 'enter'), > > > (r'^main/$', 'main'), > > > (r'^exam/(?P\d+)/$', 'exam'), > > > (r'^myexam/(?P\d+)/$', 'my_exam'), > > > (r'^solved/(?P\d+)/$', 'solved_exam'), > > > (r'^report/$', 'report'), > > > (r'^exams/$', 'exams'), > > > (r'^admin/(.*)', admin.site.root), > > > ) > > > > In the index page is called /enter and I've also tried /enter/ but > > > neither work :( > > > Try, putting FORCE_SCRIPT_NAME='' in your settings file. > > > Also, how are you running the application in your production server > > (Apache/mod_python, lighttpd/flup, nginx/proxy, etc.)? > > > -RD --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: 'NoneType' object is not iterable
Hello Rajesh, I've tried putting FORCE_SCRIPT_NAME="" but everything continues at the same state. I'm running the app in Apache2/mod_python. I've pasted the htttp.conf file at http://rafb.net/p/Ya1VKT55.html I'm going to continue trying to solve it. On Nov 5, 7:11 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > Hi Javi, > > > > > Thanks but I'd already tried it. I don't understand why in the > > production server is not added the preceeding slash to the url. My > > urls.py is as follows: > > urlpatterns = patterns('candidateTool.assessmentSystem.views', > > (r'^$', 'index'), > > (r'^enter/$', 'enter'), > > (r'^main/$', 'main'), > > (r'^exam/(?P\d+)/$', 'exam'), > > (r'^myexam/(?P\d+)/$', 'my_exam'), > > (r'^solved/(?P\d+)/$', 'solved_exam'), > > (r'^report/$', 'report'), > > (r'^exams/$', 'exams'), > > (r'^admin/(.*)', admin.site.root), > > ) > > > In the index page is called /enter and I've also tried /enter/ but > > neither work :( > > Try, putting FORCE_SCRIPT_NAME='' in your settings file. > > Also, how are you running the application in your production server > (Apache/mod_python, lighttpd/flup, nginx/proxy, etc.)? > > -RD --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: 'NoneType' object is not iterable
Hi Javi, > Thanks but I'd already tried it. I don't understand why in the > production server is not added the preceeding slash to the url. My > urls.py is as follows: > urlpatterns = patterns('candidateTool.assessmentSystem.views', > (r'^$', 'index'), > (r'^enter/$', 'enter'), > (r'^main/$', 'main'), > (r'^exam/(?P\d+)/$', 'exam'), > (r'^myexam/(?P\d+)/$', 'my_exam'), > (r'^solved/(?P\d+)/$', 'solved_exam'), > (r'^report/$', 'report'), > (r'^exams/$', 'exams'), > (r'^admin/(.*)', admin.site.root), > ) > > In the index page is called /enter and I've also tried /enter/ but > neither work :( Try, putting FORCE_SCRIPT_NAME='' in your settings file. Also, how are you running the application in your production server (Apache/mod_python, lighttpd/flup, nginx/proxy, etc.)? -RD --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: 'NoneType' object is not iterable
Thanks but I'd already tried it. I don't understand why in the production server is not added the preceeding slash to the url. My urls.py is as follows: urlpatterns = patterns('candidateTool.assessmentSystem.views', (r'^$', 'index'), (r'^enter/$', 'enter'), (r'^main/$', 'main'), (r'^exam/(?P\d+)/$', 'exam'), (r'^myexam/(?P\d+)/$', 'my_exam'), (r'^solved/(?P\d+)/$', 'solved_exam'), (r'^report/$', 'report'), (r'^exams/$', 'exams'), (r'^admin/(.*)', admin.site.root), ) In the index page is called /enter and I've also tried /enter/ but neither work :( On Nov 4, 7:07 pm, Xiong Chiamiov <[EMAIL PROTECTED]> wrote: > If it works in one environment, but not another, then it might have > something to do with your settings files. When you create your links, > are you having the href be "/enter" or "/enter/"? I think the > middleware class you're reading about is for trailing slashes, not > preceeding ones. > > On Nov 4, 9:35 am, Javi <[EMAIL PROTECTED]> wrote: > > > Hello everybody! > > I'm using django 1.0-1 version and Apache as a server web. In the dev > > server everything works fine but in the production server I get the > > following error when I ask for a url: > > > NoneType' object is not iterable > > > Request Method: POST > > Request URL: http://localhostenter/ > > Exception Type: TypeError > > Exception Value: > > > 'NoneType' object is not iterable > > > Exception Location: /var/lib/python-support/python2.5/django/core/ > > handlers/base.py in get_response, line 77 > > Python Executable: /usr/bin/python > > Python Version: 2.5.2 > > > I think it's because the "/" after "localhost" is not added, actually > > the url in the browser ishttp://localhost/enter/ > > > I've been reading about the problem and someone speaks about creating > > a middleware class... I don't know... > > > Is there another simpler way to sort the problem out? > > > Thanks in advance. > > > Greetings. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: 'NoneType' object is not iterable
If it works in one environment, but not another, then it might have something to do with your settings files. When you create your links, are you having the href be "/enter" or "/enter/"? I think the middleware class you're reading about is for trailing slashes, not preceeding ones. On Nov 4, 9:35 am, Javi <[EMAIL PROTECTED]> wrote: > Hello everybody! > I'm using django 1.0-1 version and Apache as a server web. In the dev > server everything works fine but in the production server I get the > following error when I ask for a url: > > NoneType' object is not iterable > > Request Method: POST > Request URL: http://localhostenter/ > Exception Type: TypeError > Exception Value: > > 'NoneType' object is not iterable > > Exception Location: /var/lib/python-support/python2.5/django/core/ > handlers/base.py in get_response, line 77 > Python Executable: /usr/bin/python > Python Version: 2.5.2 > > I think it's because the "/" after "localhost" is not added, actually > the url in the browser ishttp://localhost/enter/ > > I've been reading about the problem and someone speaks about creating > a middleware class... I don't know... > > Is there another simpler way to sort the problem out? > > Thanks in advance. > > Greetings. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~--~~~~--~~--~--~---