Use the new optional argument to endRequest in the middleware
authorSverre Rabbelier <srabbelier@gmail.com>
Sat, 12 Sep 2009 21:27:17 +0200
changeset 2910 60d56cf01b54
parent 2909 81eaf0a9101f
child 2911 2ddd386d1dbd
Use the new optional argument to endRequest in the middleware Currently endRequest is called twice on an exception if Django intercepts the exception and returns it's own result. By setting optional=True we do not crash on 'assert self.in_request'.
app/soc/middleware/value_store.py
--- a/app/soc/middleware/value_store.py	Sat Sep 12 21:26:27 2009 +0200
+++ b/app/soc/middleware/value_store.py	Sat Sep 12 21:27:17 2009 +0200
@@ -39,7 +39,7 @@
     core = callback.getCore()
     core.startNewRequest(request)
 
-  def end(self, request):
+  def end(self, request, optional):
     """Empties the value store.
 
     Args:
@@ -47,7 +47,7 @@
     """
 
     core = callback.getCore()
-    core.endRequest(request)
+    core.endRequest(request, optional)
 
   def process_request(self, request):
     """Called when a request is made.
@@ -64,7 +64,7 @@
     the method signature.
     """
 
-    self.end(request)
+    self.end(request, True)
     return response
 
   def process_exception(self, request, exception):
@@ -74,4 +74,4 @@
     the method signature.
     """
 
-    self.end(request)
+    self.end(request, False)