On 8/10/06, James Bennett <[EMAIL PROTECTED]> wrote: > 1) Document the way templatetag loading works, and advise tag authors > to wrap any imports they need in try/except and handle the situation > as appropriate (for example, by returning nothing from their tag, or > possibly raising ImproperlyConfigured with a message that a given > third-party module needs to be installed). This is a bit of a wart, > but at least it would get the issue documented so that people don't > have to go digging in the source to figure out what causes it. > > 2) Tweak django/templatetags/__init__.py to introspect the ImportError > it gets and figure out whether the exception came from a non-existent > 'templatetags' module (in which case it can be safely quashed) or from > something in a tag library failing to import a needed module (in which > case the exception should keep propagating in some form so it will > appear in the eventual traceback). Given that we know what the > exception would look like for a non-existent templatetag library ("No > module named myapp.templatetags"), this probably wouldn't be terribly > hard to accomplish. > > Obviously I prefer the latter, since it results in more intuitive > behavior, but I'm interested in hearing what other people think about > this.
Yeah, I agree that we should improve the templatetag loading magic. What about doing *both* -- improving the docs to note the ImportError gotcha, *and* introspecting the ImportError? How would you introspect the ImportError, anyway? By parsing the "args" attribute of the Exception object? Slightly hackish... Adrian -- Adrian Holovaty holovaty.com | djangoproject.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@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-developers -~----------~----~----~----~------~----~------~--~---