Opened 14 years ago

Closed 13 years ago

Last modified 13 years ago

#14046 closed (fixed)

Template tag errors masked if including based on context variable name

Reported by: Philip Owned by: mariarchi
Component: Template system Version: 1.2
Severity: Keywords: template exception sprintdec2010
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have a template tag that raises a RuntimeError. Normally, this gets displayed properly to the user, but I have found a case where it doesn't. If I {% include includefilename %} where includefilename is a context variable pointing to a template, then template tag errors are masked. If I do the very same include, but specify the template name directly without using the context variable, things work properly.

I have attached a barebones demo of the problem. To see the demo, runserver and check the template files. You can uncomment my includes in index.html to see the problem.

Attachments (3)

template_error_examples.tar.gz (4.2 KB ) - added by Philip 14 years ago.
patch.diff (1.7 KB ) - added by mariarchi 13 years ago.
patch.2.diff (215.3 KB ) - added by mariarchi 13 years ago.

Download all attachments as: .zip

Change History (11)

by Philip, 14 years ago

comment:1 by mariarchi, 13 years ago

Owner: changed from nobody to mariarchi
Status: newassigned

I've seen something similar in my projects before; i'll try to look into it

by mariarchi, 13 years ago

Attachment: patch.diff added

comment:2 by mariarchi, 13 years ago

Has patch: set

should work now.

comment:3 by Russell Keith-Magee, 13 years ago

Needs tests: set
Triage Stage: UnreviewedAccepted

Patch looks good,but needs tests.

comment:4 by mariarchi, 13 years ago

..and tests would in turn require rewriting a chunk of template tests, because currently they test for things only with "TEMPLATE_DEBUG=False".

I'll try to finish that tomorrow.

by mariarchi, 13 years ago

Attachment: patch.2.diff added

comment:5 by mariarchi, 13 years ago

Keywords: sprintdec2010 added
Needs tests: unset
Triage Stage: AcceptedReady for checkin

comment:6 by mariarchi, 13 years ago

Russel says "ready for check-in"

comment:7 by Russell Keith-Magee, 13 years ago

Resolution: fixed
Status: assignedclosed

In [15413]:

Fixed #14046 -- Made {% include %} behave the same, regardless of whether the template included is named by variable or constant string. Thanks to defcube for the report, and George Karpenkov for the draft patch.

comment:8 by Russell Keith-Magee, 13 years ago

In [15414]:

[1.2.X] Fixed #14046 -- Made {% include %} behave the same, regardless of whether the template included is named by variable or constant string. Thanks to defcube for the report, and George Karpenkov for the draft patch.

Backport of r15413 from trunk.

Note: See TracTickets for help on using tickets.
Back to Top