summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Pellerin <jpellerin@gmail.com>2006-08-27 16:23:57 +0000
committerJason Pellerin <jpellerin@gmail.com>2006-08-27 16:23:57 +0000
commit8c6c4454df9a76e99c625186bcc27f339bde8abf (patch)
tree6da8ef18c51fb69ad7392c8b712123516138a29d
parent88b4149df6f55b9ee1f387572405d3902606ca9d (diff)
[multi-db] Merge trunk to [3659].
git-svn-id: http://code.djangoproject.com/svn/django/branches/multiple-db-support@3664 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/template/__init__.py6
-rw-r--r--django/template/defaulttags.py2
-rw-r--r--django/template/loader.py8
-rw-r--r--django/template/loader_tags.py2
-rw-r--r--django/views/debug.py6
-rw-r--r--django/views/static.py2
6 files changed, 16 insertions, 10 deletions
diff --git a/django/template/__init__.py b/django/template/__init__.py
index ba7ca4c02b..2f68924d18 100644
--- a/django/template/__init__.py
+++ b/django/template/__init__.py
@@ -60,6 +60,8 @@ from django.conf import settings
from django.template.context import Context, RequestContext, ContextPopException
from django.utils.functional import curry
from django.utils.text import smart_split
+from django.dispatch import dispatcher
+from django.template import signals
__all__ = ('Template', 'Context', 'RequestContext', 'compile_string')
@@ -137,13 +139,14 @@ class StringOrigin(Origin):
return self.source
class Template(object):
- def __init__(self, template_string, origin=None):
+ def __init__(self, template_string, origin=None, name='<Unknown Template>'):
"Compilation stage"
if settings.TEMPLATE_DEBUG and origin == None:
origin = StringOrigin(template_string)
# Could do some crazy stack-frame stuff to record where this string
# came from...
self.nodelist = compile_string(template_string, origin)
+ self.name = name
def __iter__(self):
for node in self.nodelist:
@@ -152,6 +155,7 @@ class Template(object):
def render(self, context):
"Display stage -- can be called many times"
+ dispatcher.send(signal=signals.template_rendered, sender=self, template=self, context=context)
return self.nodelist.render(context)
def compile_string(template_string, origin):
diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
index 0a4fe33d82..d111ddca89 100644
--- a/django/template/defaulttags.py
+++ b/django/template/defaulttags.py
@@ -251,7 +251,7 @@ class SsiNode(Node):
output = ''
if self.parsed:
try:
- t = Template(output)
+ t = Template(output, name=self.filepath)
return t.render(context)
except TemplateSyntaxError, e:
if settings.DEBUG:
diff --git a/django/template/loader.py b/django/template/loader.py
index 60f24554f1..03e6f8d49d 100644
--- a/django/template/loader.py
+++ b/django/template/loader.py
@@ -76,14 +76,16 @@ def get_template(template_name):
Returns a compiled Template object for the given template name,
handling template inheritance recursively.
"""
- return get_template_from_string(*find_template_source(template_name))
+ source, origin = find_template_source(template_name)
+ template = get_template_from_string(source, origin, template_name)
+ return template
-def get_template_from_string(source, origin=None):
+def get_template_from_string(source, origin=None, name=None):
"""
Returns a compiled Template object for the given template code,
handling template inheritance recursively.
"""
- return Template(source, origin)
+ return Template(source, origin, name)
def render_to_string(template_name, dictionary=None, context_instance=None):
"""
diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py
index 7f22f207b6..b20c318f1f 100644
--- a/django/template/loader_tags.py
+++ b/django/template/loader_tags.py
@@ -57,7 +57,7 @@ class ExtendsNode(Node):
except TemplateDoesNotExist:
raise TemplateSyntaxError, "Template %r cannot be extended, because it doesn't exist" % parent
else:
- return get_template_from_string(source, origin)
+ return get_template_from_string(source, origin, parent)
def render(self, context):
compiled_parent = self.get_parent(context)
diff --git a/django/views/debug.py b/django/views/debug.py
index 6934360afd..f15eb8ff01 100644
--- a/django/views/debug.py
+++ b/django/views/debug.py
@@ -115,7 +115,7 @@ def technical_500_response(request, exc_type, exc_value, tb):
'function': '?',
'lineno': '?',
}]
- t = Template(TECHNICAL_500_TEMPLATE)
+ t = Template(TECHNICAL_500_TEMPLATE, name='Technical 500 Template')
c = Context({
'exception_type': exc_type.__name__,
'exception_value': exc_value,
@@ -141,7 +141,7 @@ def technical_404_response(request, exception):
# tried exists but is an empty list. The URLconf must've been empty.
return empty_urlconf(request)
- t = Template(TECHNICAL_404_TEMPLATE)
+ t = Template(TECHNICAL_404_TEMPLATE, name='Technical 404 Template')
c = Context({
'root_urlconf': settings.ROOT_URLCONF,
'urlpatterns': tried,
@@ -154,7 +154,7 @@ def technical_404_response(request, exception):
def empty_urlconf(request):
"Create an empty URLconf 404 error response."
- t = Template(EMPTY_URLCONF_TEMPLATE)
+ t = Template(EMPTY_URLCONF_TEMPLATE, name='Empty URLConf Template')
c = Context({
'project_name': settings.SETTINGS_MODULE.split('.')[0]
})
diff --git a/django/views/static.py b/django/views/static.py
index ac323944d0..a8c8328014 100644
--- a/django/views/static.py
+++ b/django/views/static.py
@@ -81,7 +81,7 @@ def directory_index(path, fullpath):
try:
t = loader.get_template('static/directory_index')
except TemplateDoesNotExist:
- t = Template(DEFAULT_DIRECTORY_INDEX_TEMPLATE)
+ t = Template(DEFAULT_DIRECTORY_INDEX_TEMPLATE, name='Default Directory Index Template')
files = []
for f in os.listdir(fullpath):
if not f.startswith('.'):