summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-12-02 23:57:22 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-12-02 23:57:22 +0000
commit67373009e053aca469f857be99158564fc9b42f0 (patch)
treebc27744bb9bca4cb69fecac92f07616034a39941 /django
parenta88ca126fcfe579a38f3e94a7668b626f0e468c3 (diff)
Fixed #4563 -- Context.pop/push/update return the top-level dictionary (the new
one for push() and update(), the one removed for pop()). Based on a patch from Brian Harring. git-svn-id: http://code.djangoproject.com/svn/django/trunk@6854 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/template/context.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/django/template/context.py b/django/template/context.py
index 017d2d84b1..0e41a26618 100644
--- a/django/template/context.py
+++ b/django/template/context.py
@@ -23,12 +23,14 @@ class Context(object):
yield d
def push(self):
- self.dicts = [{}] + self.dicts
+ d = {}
+ self.dicts = [d] + self.dicts
+ return d
def pop(self):
if len(self.dicts) == 1:
raise ContextPopException
- del self.dicts[0]
+ return self.dicts.pop(0)
def __setitem__(self, key, value):
"Set a variable in the current context"
@@ -62,6 +64,7 @@ class Context(object):
def update(self, other_dict):
"Like dict.update(). Pushes an entire dictionary's keys and values onto the context."
self.dicts = [other_dict] + self.dicts
+ return other_dict
# This is a function rather than module-level procedural code because we only
# want it to execute if somebody uses RequestContext.