Add optional argument to endRequest
The optional argument allows endRequest to be called more than once,
as long as any invocation after the first has optional=True.
--- a/app/soc/modules/core.py Sat Sep 12 21:25:56 2009 +0200
+++ b/app/soc/modules/core.py Sat Sep 12 21:26:27 2009 +0200
@@ -150,13 +150,18 @@
self.per_request_value = {}
self.setRequestValue('request', request)
- def endRequest(self, request):
+ def endRequest(self, request, optional):
"""Performs cleanup after current request.
Args:
request: a Django HttpRequest object
+ optional: whether to noop when not in a request
"""
+ # already cleaned up, as expected
+ if optional and not self.in_request:
+ return
+
old_request = self.getRequestValue('request')
self.per_request_value = {}
self.in_request = False