#8809: Better error message when can't import url callback
------------------------------------------+---------------------------------
Reporter: TP | Owner: v1v3kn
Status: assigned | Milestone:
Component: Core framework | Version: SVN
Resolution: | Keywords: error message
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 1
Patch needs improvement: 1 |
------------------------------------------+---------------------------------
Changes (by carljm):
* needs_better_patch: 0 => 1
Comment:
This patch makes a number of assumptions that are not reliable:
1. That url patterns are always found in a file named "urls.py" (in fact
they can be in any module, or even just an object with a get_urls()
method).
2. That the exact string in the RegexURLPattern._callback attribute can be
found literally in the urls.py file (this will fail when the prefix
argument to "patterns" is used; also, the view string could be constructed
dynamically via string interpolation).
Also, the patch needs an automated test, integrated in Django's test
suite.
I don't see any way that this approach (trying to reconstruct the
information after the fact by literal searching in code files) will be
workable. The information instead needs to be preserved from the initial
definition in the urls.py if it's to be provided later in the error. The
easiest way to do this would be to resolve the import immediately rather
than lazily, but that's not acceptable as it could cause circular import
issues in cases that currently work. The only alternatives I can see at
the moment (having not looked into it deeply yet) would involve some
rather nasty frame-object magic. This is not going to be a simple or easy
fix.
--
Ticket URL: <http://code.djangoproject.com/ticket/8809#comment:6>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" 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-updates?hl=en.