summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorLuke Plant <L.Plant.98@cantab.net>2011-02-27 00:24:35 +0000
committerLuke Plant <L.Plant.98@cantab.net>2011-02-27 00:24:35 +0000
commit2366415f48282faef6e45993b08d1dec1f0b5e35 (patch)
tree56df1ef81288e00539ef9f69beb1c02bf1ff4995 /django
parentb5b5ba6cd9179372cead3e6d19f732285e80b799 (diff)
Fixed #15368 - test failures due to regression with RequestContext
Thanks to cyberdelia for the reports on this. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15660 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/template/context.py24
1 files changed, 9 insertions, 15 deletions
diff --git a/django/template/context.py b/django/template/context.py
index cf0c929065..1c8b7dacd9 100644
--- a/django/template/context.py
+++ b/django/template/context.py
@@ -14,14 +14,21 @@ class ContextPopException(Exception):
"pop() has been called more times than push()"
pass
+class EmptyClass(object):
+ # No-op class which takes no args to its __init__ method, to help implement
+ # __copy__
+ pass
+
class BaseContext(object):
def __init__(self, dict_=None):
dict_ = dict_ or {}
self.dicts = [dict_]
def __copy__(self):
- duplicate = self._new()
- duplicate.dicts = [dict_ for dict_ in self.dicts]
+ duplicate = EmptyClass()
+ duplicate.__class__ = self.__class__
+ duplicate.__dict__ = self.__dict__.copy()
+ duplicate.dicts = duplicate.dicts[:]
return duplicate
def __repr__(self):
@@ -31,9 +38,6 @@ class BaseContext(object):
for d in reversed(self.dicts):
yield d
- def _new(self):
- return self.__class__()
-
def push(self):
d = {}
self.dicts.append(d)
@@ -88,11 +92,6 @@ class Context(BaseContext):
duplicate.render_context = copy(self.render_context)
return duplicate
- def _new(self):
- return self.__class__(autoescape=self.autoescape,
- current_app=self.current_app,
- use_l10n=self.use_l10n)
-
def update(self, other_dict):
"Pushes other_dict to the stack of dictionaries in the Context"
if not hasattr(other_dict, '__getitem__'):
@@ -168,8 +167,3 @@ class RequestContext(Context):
processors = tuple(processors)
for processor in get_standard_processors() + processors:
self.update(processor(request))
-
- def _new(self):
- return self.__class__(request=HttpRequest(),
- current_app=self.current_app,
- use_l10n=self.use_l10n)