Opened 16 years ago

Closed 12 years ago

#8135 closed New feature (wontfix)

Make RequestContext act as a dictionary

Reported by: Marc Garcia Owned by: nobody
Component: Template system Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When creating the context, using RequestContext to include context processors content, the next doesn't work:

 context = dict(example=value)
 context.update(RequestContext(request))

instead I can use

 context = requestContext(request)
 context.update(dict(example=value))

but I think that also allowing the first case would avoid some confusion.

Change History (9)

comment:1 by Matthias Kestenholz, 16 years ago

This ticket makes not much sense to me. The Context is more than a simple dict, it is a stack container offering functions which cannot be easily emulated using a dict.

Although it would be possible to further emulate a dict I think this would send a wrong message to the user. Why would you want to construct a RequestContext, update a dict with it and then again create a Context to render the template?

comment:2 by Eric Holscher, 16 years ago

milestone: post-1.0
Triage Stage: UnreviewedDesign decision needed

I ran into this as well, but don't know if it's a "good thing"

comment:3 by Julien Phalip, 16 years ago

Triage Stage: Design decision neededAccepted

This is a valid point. The context is generally assumed to be a dictionary, so RequestContext should behave as such.

comment:4 by Julien Phalip, 16 years ago

Triage Stage: AcceptedDesign decision needed

Ok, after a second thought, there's an easy way around this:

from django.template import Context
context = Context(dict(example=value))
context.update(RequestContext(request))

comment:5 by (none), 16 years ago

milestone: post-1.0

Milestone post-1.0 deleted

comment:6 by Luke Plant, 14 years ago

Severity: Normal
Type: New feature

comment:7 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:8 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:9 by Florian Apolloner, 12 years ago

Resolution: wontfix
Status: newclosed

I don't see much gain in it -- especially since one usually passes RequestContext as context_instance and not via the normal dict.

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