#13470: Debug TEMPLATE_LOADERS causes 'source' to be set to "<unknown
source>" when TEMPLATE_DEBUG is True
-------------------------------------------+--------------------------------
          Reporter:  sdei...@wingware.com  |         Owner:  nobody             
                                          
            Status:  new                   |     Milestone:  1.2                
                                          
         Component:  Uncategorized         |       Version:  1.2-beta           
                                          
        Resolution:                        |      Keywords:  settings 
template_debug template_loaders template node source
             Stage:  Unreviewed            |     Has_patch:  1                  
                                          
        Needs_docs:  0                     |   Needs_tests:  0                  
                                          
Needs_better_patch:  0                     |  
-------------------------------------------+--------------------------------
Changes (by Alex):

  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * needs_docs:  => 0

Old description:

> A work around is to set settings.py TEMPLATE_LOADERS to start with (or
> contain only) the following:
>
>     'django.template.loaders.filesystem.load_template_source',
>     'django.template.loaders.app_directories.load_template_source',
>
> However, it seems it would be good to properly set 'source' on nodes when
> TEMPLATE_DEBUG is True.  To fix this, change template/loader.py's
> BaseLoader.load_template to read as follows so that an origin object
> is properly created and sent into get_template_from_string when
> TEMPLATE_DEBUG is True:
>
>     def load_template(self, template_name, template_dirs=None):
>         source, origin = self.load_template_source(template_name,
> template_dirs)
>         origin_obj = make_origin(origin, self, template_name,
> template_dirs)
>         template = get_template_from_string(source, origin=origin_obj,
> name=template_name)
>         return template, origin
>
> This is based on the 1.2beta-1 release.

New description:

 A work around is to set settings.py TEMPLATE_LOADERS to start with (or
 contain only) the following:
 {{{
     'django.template.loaders.filesystem.load_template_source',
     'django.template.loaders.app_directories.load_template_source',
 }}}
 However, it seems it would be good to properly set 'source' on nodes when
 TEMPLATE_DEBUG is True.  To fix this, change template/loader.py's
 BaseLoader.load_template to read as follows so that an origin object
 is properly created and sent into get_template_from_string when
 TEMPLATE_DEBUG is True:
 {{{
     def load_template(self, template_name, template_dirs=None):
         source, origin = self.load_template_source(template_name,
 template_dirs)
         origin_obj = make_origin(origin, self, template_name,
 template_dirs)
         template = get_template_from_string(source, origin=origin_obj,
 name=template_name)
         return template, origin
 }}}
 This is based on the 1.2beta-1 release.

Comment:

 Please use preview.

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