Add self.in_request to Core and verify correct state
authorSverre Rabbelier <srabbelier@gmail.com>
Sat, 29 Aug 2009 14:32:14 -0700
changeset 2849 c0462a1d3958
parent 2848 17a31a7e6abc
child 2850 c935cb48f757
Add self.in_request to Core and verify correct state
app/soc/modules/core.py
--- a/app/soc/modules/core.py	Sat Aug 29 14:31:26 2009 -0700
+++ b/app/soc/modules/core.py	Sat Aug 29 14:32:14 2009 -0700
@@ -111,6 +111,7 @@
     self.sitemap = []
     self.sidebar = []
     self.per_request_cache = {}
+    self.in_request = False
 
   ##
   ## internal
@@ -142,6 +143,7 @@
     """Prepares core to handle a new request.
     """
 
+    self.in_request = True
     self.per_request_value = {}
     self.setRequestValue('request', request)
 
@@ -151,6 +153,7 @@
 
     old_request = self.getRequestValue('request')
     self.per_request_value = {}
+    self.in_request = False
 
     if id(old_request) != id(request):
       logging.error("ending request: \n'%s'\n != \n'%s'\n" % (
@@ -160,12 +163,14 @@
     """Gets a per-request value.
     """
 
+    assert self.in_request
     return self.per_request_value.get(key, default)
 
   def setRequestValue(self, key, value):
     """Sets a per-request value.
     """
 
+    assert self.in_request
     self.per_request_value[key] = value
 
   def getPatterns(self):