Opened 17 years ago

Closed 17 years ago

#3749 closed (fixed)

FilterNode does not supply full context

Reported by: Zak Johnson <zakj@…> Owned by: Adrian Holovaty
Component: Template system Version: dev
Severity: Keywords: FilterNode filter tag
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

FilterNode truncates the context it passes to its filter, causing variable filter arguments to raise VariableDoesNotExist. For example, this works:

{{ obj|cut:request.GET.cut }}

This raises VariableDoesNotExist:

{% filter cut:request.GET.cut %}{{ obj }}{% endfilter %}

Attachments (2)

FilterNode.patch (600 bytes ) - added by Zak Johnson <zakj@…> 17 years ago.
FilterNode.2.patch (1.3 KB ) - added by Zak Johnson <zakj@…> 17 years ago.
patch with regression test

Download all attachments as: .zip

Change History (10)

by Zak Johnson <zakj@…>, 17 years ago

Attachment: FilterNode.patch added

comment:1 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedReady for checkin

comment:2 by Adrian Holovaty, 17 years ago

Needs tests: set
Triage Stage: Ready for checkinAccepted

Thanks for the patch. Could you (or somebody) include some unit tests, so we can check this in?

by Zak Johnson <zakj@…>, 17 years ago

Attachment: FilterNode.2.patch added

patch with regression test

comment:3 by Zak Johnson <zakj@…>, 17 years ago

Needs tests: unset
Triage Stage: AcceptedReady for checkin

comment:4 by Chris Beaven, 17 years ago

Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

Maybe I'm missing something, but context is being popped at the end of the render method even though it was never pushed. Won't this screw up the context after this node?

comment:5 by Zak Johnson <zakj@…>, 17 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

Context.update() pushes its argument to the beginning of the context. See http://code.djangoproject.com/browser/django/trunk/django/template/context.py#L61. All unit tests pass following this patch.

comment:6 by Chris Beaven, 17 years ago

My mistake, thanks for checking this - I didn't get around to doing it myself.

comment:7 by Zak Johnson <zakj@…>, 17 years ago

No worries; you've got a lot of tickets to get through. :)

comment:8 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: newclosed

(In [5052]) Fixed #3749 -- Set the context correctly when using the "filter" template tag.
Thanks, Zak Johnson.

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