Skip to content

Commit aa85e5e

Browse files
committed
ApplicationContent: Keep the modified URLconf environment until the end of process()
1 parent 07374ad commit aa85e5e

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

feincms/content/application/models.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -317,31 +317,32 @@ def process(self, request, **kwargs):
317317

318318
try:
319319
output = fn(request, *args, **kwargs)
320+
321+
if isinstance(output, HttpResponse):
322+
if self.send_directly(request, output):
323+
return output
324+
elif output.status_code == 200:
325+
326+
# If the response supports deferred rendering, render the
327+
# response right now. We do not handle template response
328+
# middleware.
329+
if hasattr(output, 'render') and callable(output.render):
330+
output.render()
331+
332+
self.rendered_result = mark_safe(output.content.decode('utf-8'))
333+
self.rendered_headers = {}
334+
# Copy relevant headers for later perusal
335+
for h in ('Cache-Control', 'Last-Modified', 'Expires'):
336+
if h in output:
337+
self.rendered_headers.setdefault(h, []).append(output[h])
338+
else:
339+
self.rendered_result = mark_safe(output)
340+
320341
finally:
321342
# We want exceptions to propagate, but we cannot allow the
322343
# modifications to reverse() to stay here.
323344
del _local.urlconf
324345

325-
if isinstance(output, HttpResponse):
326-
if self.send_directly(request, output):
327-
return output
328-
elif output.status_code == 200:
329-
330-
# If the response supports deferred rendering, render the
331-
# response right now. We do not handle template response
332-
# middleware.
333-
if hasattr(output, 'render') and callable(output.render):
334-
output.render()
335-
336-
self.rendered_result = mark_safe(output.content.decode('utf-8'))
337-
self.rendered_headers = {}
338-
# Copy relevant headers for later perusal
339-
for h in ('Cache-Control', 'Last-Modified', 'Expires'):
340-
if h in output:
341-
self.rendered_headers.setdefault(h, []).append(output[h])
342-
else:
343-
self.rendered_result = mark_safe(output)
344-
345346
return True # successful
346347

347348
def send_directly(self, request, response):

0 commit comments

Comments
 (0)