Opened 14 years ago

Last modified 10 years ago

#13841 assigned New feature

Allow context processors access to current version of context

Reported by: Mitar Owned by: Colin Copeland
Component: Template system Version: dev
Severity: Normal Keywords:
Cc: mmitar@…, vbmendes@…, simon@…, copelco@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Allow context processors access to current version of context so that they can change values and not just override them. This can be easily done with another argument, context, and also backwards compatible. Functions would only get additional argument if they are defined to get two arguments and whatever they would return would override that in the context.

Attachments (3)

ticket13841.diff (875 bytes ) - added by Simon Litchfield 14 years ago.
13841-docs.diff (1.1 KB ) - added by Simon Litchfield 14 years ago.
Updated docs.
13841_tests_docs.diff (4.7 KB ) - added by Colin Copeland 13 years ago.
Combined diff with tests and docs

Download all attachments as: .zip

Change History (18)

comment:1 by Mitar, 14 years ago

I could make a patch if there would be an agreement that this is useful.

comment:2 by vbmendes, 14 years ago

Cc: vbmendes@… added

I think this is a very useful feature. It also allows to develop context processor that add a context variable based in another context variable.

comment:3 by Gregor Müllegger, 14 years ago

mitar:

I could make a patch if there would be an agreement that this is useful.

It seems that you want to discuss this first before implementing. The best place for discussion is the django-developers mailinglist[1] - writing your proposal there will result in better feedback and you can get an idea if core developers also find this useful and would accept a patch.

[1] http://groups.google.com/group/django-developers

comment:4 by Mitar, 14 years ago

There was completely no response on the mailing list.

comment:5 by Russell Keith-Magee, 14 years ago

Triage Stage: UnreviewedAccepted

This seems like a reasonable feature request; however, the implementation will need to be very careful about backwards compatibility.

comment:6 by Simon Litchfield, 14 years ago

Cc: simon@… added

Mitar, this sounds good. Any thoughts on syntax? Maybe something like --

def mycontextprocesser(request, context=None):
    ...

by Simon Litchfield, 14 years ago

Attachment: ticket13841.diff added

comment:7 by Simon Litchfield, 14 years ago

Patch attached. Backwards compatible, shouldn't add overhead either (getargspec is only called once for each processor) --

def mycontextprocessor(request):
    ...

def mycontextprocessor(request, context):
    print context.get('request')

by Simon Litchfield, 14 years ago

Attachment: 13841-docs.diff added

Updated docs.

comment:8 by Simon Litchfield, 14 years ago

Has patch: set
milestone: 1.4
Owner: changed from nobody to Russell Keith-Magee
Version: 1.2SVN

comment:9 by Russell Keith-Magee, 14 years ago

Owner: changed from Russell Keith-Magee to nobody

@simon29 - Please don't assign bugs to me without speaking to me first.

comment:10 by Graham King, 14 years ago

Severity: Normal
Type: New feature

comment:11 by Julien Phalip, 14 years ago

Needs tests: set

The patch needs tests. Could you also combine everything (new feature, tests and doc) within one single diff patch?

comment:12 by Colin Copeland, 13 years ago

Easy pickings: unset
Owner: changed from nobody to Colin Copeland
Status: newassigned
UI/UX: unset

by Colin Copeland, 13 years ago

Attachment: 13841_tests_docs.diff added

Combined diff with tests and docs

comment:13 by Colin Copeland, 13 years ago

Cc: copelco@… added
Needs tests: unset
Version 0, edited 13 years ago by Colin Copeland (next)

comment:14 by Jacob, 13 years ago

milestone: 1.4

Milestone 1.4 deleted

comment:15 by Tim Graham, 10 years ago

Patch needs improvement: set
Note: See TracTickets for help on using tickets.
Back to Top