#17199: Base Template Loader should return the origin
---------------------------------+--------------------------------------
     Reporter:  Kronuz           |                    Owner:  nobody
         Type:  Bug              |                   Status:  closed
    Component:  Template system  |                  Version:  SVN
     Severity:  Normal           |               Resolution:  needsinfo
     Keywords:                   |             Triage Stage:  Unreviewed
    Has patch:  1                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+--------------------------------------

Comment (by Kronuz):

 Using `TEMPLATE_DEBUG = True` (so that origin is returned, otherwise
 origin is never actually returned, see `make_origin()` in
 `django.template.loader`), if I do: `template, origin =
 loader.find_template('mytemplate.html')`, it does not return origin (this
 is because `load_template()` in `BaseLoader` explicitly returns None
 instead of the origin). Same thing with the `load_template()` in the
 "cached" loader. It returns the tuple `(template, None)`.

 After reading that bit of documentation, I can see `load_template()`
 doesn't even remotely return (as it should) a template_origin, but a
 string with the `display_name` (and only if the template is not found). I
 could also make a new patch that would make django consistent with said
 behavior in the documentation, however, `BaseLoader.load_template()`
 currently already returns `display_name` instead of the `origin`, and
 simply changing that could break some things.

 In my opinion, as I said first, `load_template()` should always return
 origin (as stated in the documentation) and not `display_name`... and only
 when the template is not found. Whether it should always return origin
 (even if `TEMPLATE_DEBUG` is not enabled) is yet another dilemma, as the
 documentation never states `load_template()` returns `template_origin`
 *only* if `TEMPLATE_DEBUG` is enabled.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17199#comment:4>
Django <https://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 django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to