﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
911	[patch] Make template system scoped to the parser	rjwittams	Adrian Holovaty	"So currently, template tags and filters are loaded into module level dictionaries. 
This means that tags and filters are available in places that they haven't been loaded. 

What this leads to is namespace pollution by previous requests - so your code might work one minute, as a previous request loaded the lib, and break the next if you are the first request. 

So this patch moves filters and tags onto parsers. As a bonus, filters are now parsed at compile time rather than runtime, so they don't get parsed multiple times in loops. 

The changes are:
At the top of a tag/filter library, 
do
{{{
import django.core.template 

register = template.Library()
}}}
then to register tags or filters, use
{{{
register.tag('name', func)
register.filter('name', func, False)
}}}
In tags, resolve_variable_with_filters is gone. 
The functionality is split in two. 
In your compile function, do 
{{{
filter_expr =  parser.compile(filter_string)
}}}
pass this into your node class as usual. 

in render, do 
{{{
filter_result = filter_expr.resolve(context) 
}}}
instead of resolve_variable_with_filters. 

the tag decorators are also now members of the library class, so do
{{{
@register.simple_tag
}}}

and 
{{{
@register.inclusion_tag('cow_detail')
}}}
for those. 

Will upload patch after updating to take account of new-admin merge. "	defect	new	contrib.admin		normal				Unreviewed	1	0	0	0	0	0
