Re: debugging server code problems in server code that is invoked via ajax request
On 25 fév, 17:06, Margie Roginskiwrote: > Hi - thanks for your responses. Was on vacation and forgot to check > back on this thread. The idea of middleware is good. I'm not sure, > however, if the views.py code generates an exception, that it can be > caught by the middleware? How do you think Django display that nice error page instead of a raw "Internal Servor Error" ?-) http://docs.djangoproject.com/en/1.1/topics/http/middleware/#process-exception -- 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.
Re: debugging server code problems in server code that is invoked via ajax request
Possibly useful tip: Note that if you use request.is_ajax() in your django views, you can also use e.g. the "Modify Headers" firefox plugin to simply pretend to django that an ordinary request you've e.g. typed into your browser address bar is an "ajax" request, with a rule e.g. Action Name ValueComment "Modify" "X-Requested-With" "XMLHttpRequest" "Fake AJAX Request" Quite handy (there's a gui for enabling/disabling rules with a click) https://addons.mozilla.org/en-US/firefox/addon/967 -- 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.
Re: debugging server code problems in server code that is invoked via ajax request
Hi - thanks for your responses. Was on vacation and forgot to check back on this thread. The idea of middleware is good. I'm not sure, however, if the views.py code generates an exception, that it can be caught by the middleware? I guess the question is how to catch exceptions. The views.py code is invoked by the django code, so on a normal request, that django code must catch the exception and then send it as a response to the client. On a non-ajax request, the response just gets displayed in the browser. But on an ajax request, unless I do some special stuff, I guess that response doesn't get displayed. So the question becomes how to catch the exception and put it somewhere useful, and I'm still not clear if I can use middleware to do that. One thing that I realize is that if I just make a request to the same address that the ajax request is going to, then I do see the error trace in my browser, so that's helpful and that's the tact I have been taking lately. Margie On Feb 12, 2:33 am, bruno desthuillierswrote: > On Feb 11, 10:27 pm, MargieRoginski wrote: > > > I have a question about debugging django server side code in the case > > where the request is an ajax request. > > From the server-side POV, a request is a request is a request. Truth > is : there's no such thing as an "ajax request". > > > For example I have an > > autocomplete widget. It makes a request to a particular url that > > takes me to one of my views.py functions, get_users(request). If I > > have some sort of error in that function, I don't see the error > > anywhere and it just silently fails. > > It's your client code that fails to handle the case properly. > > > If I explicitly put that url > > into the address bar then the error comes up in my browser, or if I > > use pdb to put a break point and then step through my code, I see the > > error. In the case of an ajax request, > > cf above. > > > what happens to the error > > from the server code and is there any way to see it? > > yes : look at the response content. Firebug is your friend - it lets > you trace and inspect XMLHttpRequests and their responses. Also, you > may want to have a "logging" middleware that logs unhandled errors - > this is useful both in dev or in production. > > HTH -- 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.
Re: debugging server code problems in server code that is invoked via ajax request
On Feb 11, 10:27 pm, Margie Roginskiwrote: > I have a question about debugging django server side code in the case > where the request is an ajax request. >From the server-side POV, a request is a request is a request. Truth is : there's no such thing as an "ajax request". > For example I have an > autocomplete widget. It makes a request to a particular url that > takes me to one of my views.py functions, get_users(request). If I > have some sort of error in that function, I don't see the error > anywhere and it just silently fails. It's your client code that fails to handle the case properly. > If I explicitly put that url > into the address bar then the error comes up in my browser, or if I > use pdb to put a break point and then step through my code, I see the > error. In the case of an ajax request, cf above. > what happens to the error > from the server code and is there any way to see it? yes : look at the response content. Firebug is your friend - it lets you trace and inspect XMLHttpRequests and their responses. Also, you may want to have a "logging" middleware that logs unhandled errors - this is useful both in dev or in production. HTH -- 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.
Re: debugging server code problems in server code that is invoked via ajax request
On Thu, Feb 11, 2010 at 4:31 PM, Javier Guerrawrote: > unfortunately, it doesn't render HTML responses... i'm glad to report i was wrong! it _does_ render content as HTML on a new tab. -- Javier -- 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.
Re: debugging server code problems in server code that is invoked via ajax request
On Thu, Feb 11, 2010 at 4:27 PM, Margie Roginskiwrote: > In the case of an ajax request, what happens to the error > from the server code and is there any way to see it? i use firebug. it lets you see every http interaction. with contents and all. unfortunately, it doesn't render HTML responses... -- Javier -- 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.
debugging server code problems in server code that is invoked via ajax request
I have a question about debugging django server side code in the case where the request is an ajax request. For example I have an autocomplete widget. It makes a request to a particular url that takes me to one of my views.py functions, get_users(request). If I have some sort of error in that function, I don't see the error anywhere and it just silently fails. If I explicitly put that url into the address bar then the error comes up in my browser, or if I use pdb to put a break point and then step through my code, I see the error. In the case of an ajax request, what happens to the error from the server code and is there any way to see it? This is all using ./manage.py runserver. I'm not concerned with the deployment environment at all. Margie -- 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.