#15102: find_template returns compiled Template object instead of template 
source
-------------------------------------+-------------------------------------
               Reporter:  vmanchev   |        Owner:  vmanchev
                   Type:             |       Status:  assigned
  Uncategorized                      |    Component:  Template system
              Milestone:             |     Severity:  Normal
                Version:  1.3        |     Keywords:  find_template
             Resolution:             |  template source
           Triage Stage:  Design     |    Has patch:  1
  decision needed                    |  Needs tests:  0
    Needs documentation:  0          |
Patch needs improvement:  0          |
-------------------------------------+-------------------------------------
Changes (by adamnfish):

 * version:  1.2 => 1.3
 * type:   => Uncategorized
 * severity:   => Normal


Comment:

 The problem with dropping support for fetching just the template's source
 is that it makes it much harder to integrate another template language
 into projects. If find_template_source exists, we can use it to fetch
 templates in a way that is well documented without having to resort to
 additional settings or duplication of Django's code. The key is that
 developers should be able to specify the correct Loaders and customise
 their template locations in a template-agnostic fashion.

 For developers who created their projects prior to v1.2, the auto-
 generated TEMPLATE_LOADERS setting has always pointed at the old (now
 deprecated) loader and only now, having upgraded to Django 1.3 are they a)
 seeing loud deprecation warnings and b) finding that these warnings cannot
 easily be worked around!

 The new implementation couples the Loader classes to Django's Template
 object in line 48 of loader.py (1.3 tag) `template =
 get_template_from_string(source, origin, template_name)`. This is a real
 shame, because Django has cleverly fetched the source and template_name
 which is exactly what is needed to integrate another template language!

 I agree that altering `find_template`'s signature doesn't feel like the
 correct approach - ideally `find_template_source` will make a re-
 appearance. It could use the `load_template_source` method of each Loader
 defined in the settings to fetch the actual source without creating a
 Django Template object.

 I also think that the variables should be renamed to properly reflect
 whether they refer to the source (a string or string-like-object
 representing the template's source code) or a template instance (a Django
 template object with a render method). This is a very important
 distinction but it is very hard to tell the difference for a given
 location by looking at Django's source code. (one has to follow the
 variable all the way up the call chain to check if
 `get_template_from_string` has already been called on it!)

 Let me know if this sounds sensible and I can look into implementing these
 changes.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15102#comment:7>
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 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