Re: advice on debugging ajax apps in django (possibly OT)

2006-09-02 Thread clee

It is possible to pop up django's traceback as a separate window when
making XMLHttpRequests.

I have found an example of placing the error content from the response
into a separate window. This is a bit easier to read than scanning
through the raw html in firebug. This appears to work for me on IE 6. A
slight modification allows it to work in firefox as well.

The source url is
http://www.onlamp.com/pub/a/onlamp/2005/05/19/xmlhttprequest.html

To adapt this to MochiKit, you just need to know that the original
XMLHttpRequest object is stored in the error object as this.req. I pass
this to the handleErrFullPage function as resp.req.responseText.  I've
pasted in my code below for my error callback function as well as for
the handleErrFullPage function.

Thanks for everyone's help.
-
function errorcallback(resp) {

switch (resp.number) {
case 500:

  handleErrFullPage(resp.req.responseText);
}


function handleErrFullPage(strIn) {

  var errorWin;
// Create new window and display error
  try {
errorWin = window.open('', 'errorWin');
// errorWin.document.body.innerHTML = strIn; // works in IE 6
errorWin.document.write(strIn); // works in firefox and IE6

  }
  // If pop-up gets blocked, inform user
  catch(e) {
alert('An error occurred, but the error message cannot be' +
' displayed because of your browser\'s pop-up
blocker.\n' +
  'Please allow pop-ups from this Web site.');
  }
}


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: advice on debugging ajax apps in django (possibly OT)

2006-08-29 Thread clee

Thank you. I've found django/test/client.py in svn.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Re: advice on debugging ajax apps in django (possibly OT)

2006-08-29 Thread James Bennett

On 8/29/06, clee <[EMAIL PROTECTED]> wrote:
> Thank you, I just downloaded firebug and it looks like a big step
> forward.

You might also want to look at the new testing support that went into
Django recently -- we've always had support for using doctest, but
unittest has just been added and there's a special-purpose class --
django.test.client.Client -- which will let you send test requests to
an application and compare the output against what you're expecting.
It's brand spanking new and not entirely documented, but the code is
pretty clean and well-commented, and official documentation will
hopefully be sorted out shortly.


-- 
"May the forces of evil become confused on the way to your house."
  -- George Carlin

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: advice on debugging ajax apps in django (possibly OT)

2006-08-29 Thread clee

Thank you, I just downloaded firebug and it looks like a big step
forward.
-chris


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: advice on debugging ajax apps in django (possibly OT)

2006-08-29 Thread [EMAIL PROTECTED]

Firebug http://www.joehewitt.com/software/firebug/ has helped me out a
ton.  In it's console firebug shows every ajax request, and if there is
an http 500 error you can see the entire response.  So you don't see
the nicely formated django error page, but you see the html source of
the nicely formated django page.  So at least you can see the stack
trace.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



advice on debugging ajax apps in django (possibly OT)

2006-08-29 Thread clee

Hello, I'm a long-time python user who is new to django, javascript,
and Mochikit. I'm very pleased with django so far but I'm having a bit
of a quandry as I start to mix in javascript and Mochikit.

One thing I like about django is that if I make an error in my python
code it send me that great debug/traceback page.  This works well if I
submit a form as well. However, I've stared to get more adventurous
with Mochikit and am trying to communicate with the server outside of a
form.

Of course, as I experiment, I make mistakes and I get back to my
javascript console (thank you mochikit) a status=500 error and an
xmlHttpRequest failed error.

I know I made a mistake in my python code in views.py, and I know that
django probably caught it and generated a traceback but I dont' know
how to look at it.

This has slowed down my coding cycle a great deal. Do others have
tricks to get at this? Is it stored in the failed response on the
javascript side? It seems if I could get access to it I could pop up a
window and display it or log it somewhere.

Many thanks for any help in advance. I will put a little code below to
give an idea of what I'm doing.

-chris


=== example ===
in my template I might have something like this in the