I've been working through "Practical Django Projects" by James Bennet.
I came across some unexpected behaviour which I wanted to share
regarding handling errors on startup within the urls configuration.

In the weblog application he talks you through, he discusses splitting
up urls.py into modules. You end up with four files within a urls
module.

  urls/entries.py
  urls/links.py
  urls/categories.py
  urls/tags.py

Now my tags.py module had an error in it. I had restarted the server
and sure enough when I went to the site (to the default entries view)
it was raised. The error was a missing model import in tags.py (and
that's what the error said to me). However, if I just ignored it and
refreshed the screen again the error did not appear again. I'm
guessing this is because Django assumes my url regexes have been
compiled and it doesn't run that code again to get the error.

So I'm sitting using the site thinking everything is fine but actually
there's a whole bunch of urls that don't work because (I'm assuming)
they would have been compiled in after the url/tags.py failed. Of
course I should not have ignored the error. I foolishly thought that
it was a 'glitch'. My bad.

However, should Django have 'known' that it's url loading had failed
and forced it to be redone when the next request came in? Could Django
know that in this instance? Having a site running with your url
configuration only partly loaded doesn't feel right to me.

Comments welcomed. I'm not likely to make the same mistake again but
interested to know if there's a solution for this. Besides the obvious
"Don't ignore error messages" :)

This was using the newforms-admin branch by the way, just in case
anything has changed there regarding this.

Ian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to