Fixed #7116 -- Optimize RequestContext construction

This commit is contained in:
Curtis Maloney 2013-08-29 14:08:01 +10:00 committed by Anssi Kääriäinen
parent 5cdacbda03
commit 8d473b2c54
2 changed files with 12 additions and 1 deletions

View File

@ -180,5 +180,7 @@ class RequestContext(Context):
processors = () processors = ()
else: else:
processors = tuple(processors) processors = tuple(processors)
updates = dict()
for processor in get_standard_processors() + processors: for processor in get_standard_processors() + processors:
self.update(processor(request)) updates.update(processor(request))
self.update(updates)

View File

@ -1843,3 +1843,12 @@ class RequestContextTests(unittest.TestCase):
template.Template('{% include "child" only %}').render(ctx), template.Template('{% include "child" only %}').render(ctx),
'none' 'none'
) )
def test_stack_size(self):
"""
Regression test for #7116, Optimize RequetsContext construction
"""
ctx = RequestContext(self.fake_request, {})
# The stack should now contain 3 items:
# [builtins, supplied context, context processor]
self.assertEqual(len(ctx.dicts), 3)