Code

Opened 8 years ago

Closed 8 years ago

#2637 closed defect (fixed)

[patch] Filters no longer parsed for unresolved variables

Reported by: SmileyChris Owned by: russellm
Component: Template system Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Changeset [3268] made the following change for the resolve method in django/template/init.py:

-            obj = settings.TEMPLATE_STRING_IF_INVALID
+            if ignore_failures:
+                return None
+            else:
+                return settings.TEMPLATE_STRING_IF_INVALID

Because TEMPLATE_STRING_IF_INVALID is returned now rather than being set in obj (which is then passed to any filters), the filters are not parsed on an unresolved variable.
This changes the behaviour of the default and default_if_none filters.

I believe the last line of that patch should have been:

+                obj = settings.TEMPLATE_STRING_IF_INVALID

Perhaps the return None line should change as well, but it's just used in testing at the moment.

Attachments (0)

Change History (3)

comment:1 Changed 8 years ago by russellm

  • Owner changed from adrian to russellm

comment:2 Changed 8 years ago by SmileyChris

Here's the related thread on Google groups

comment:3 Changed 8 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(In [3714]) Fixes #2637 -- Clarified handling of TEMPLATE_STRING_IF_INVALID, especially with regards to filtering of invalid values. Modified unit tests to test both empty and non-empty values for TEMPLATE_STRING_IF_INVALID. Thanks to SmileyChris for identifying and helping to resolve this bug.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.