blob: b06679b7ec97f1c7322fbd8c9f326ada346c0b34 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
from django.template import Origin, TemplateDoesNotExist
import django.template.loaders.base
# Store in TLS, since a template loader can't access the request
try:
from threading import local
except ImportError:
from django.utils._threading_local import local
_thread_locals = local()
def initialize_template_collection():
_thread_locals.templates = []
def get_all_templates():
return getattr(_thread_locals, 'templates', [])
class TrackingTemplateLoader(django.template.loaders.base.Loader):
def get_template_sources(self, template_name):
_thread_locals.templates = getattr(_thread_locals, 'templates', []) + [template_name, ]
yield Origin(None)
def get_contents(self, origin):
raise TemplateDoesNotExist(origin)
|