changeset 2007:6cc2e0544657

add finish handlers finish handlers can be added to the request by any part of the code to do some work when the request has been handled.
author Johannes Berg <johannes AT sipsolutions DOT net>
date Fri, 20 Apr 2007 15:33:50 +0200
parents 1339d6fdc4ff
children 52c474b8c02f
files MoinMoin/request/WSGI.py MoinMoin/request/__init__.py
diffstat 2 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/request/WSGI.py	Fri Apr 20 00:12:50 2007 +0200
+++ b/MoinMoin/request/WSGI.py	Fri Apr 20 15:33:50 2007 +0200
@@ -60,9 +60,6 @@
     def flush(self):
         pass
 
-    def finish(self):
-        pass
-
     def output(self):
         # called by MoinMoin.server.wsgi
         return self.stdout.getvalue()
--- a/MoinMoin/request/__init__.py	Fri Apr 20 00:12:50 2007 +0200
+++ b/MoinMoin/request/__init__.py	Fri Apr 20 15:33:50 2007 +0200
@@ -137,6 +137,8 @@
         # request. we do it for all request types to avoid similar problems.
         set_umask()
 
+        self._finishers = []
+
         # Decode values collected by sub classes
         self.path_info = self.decodePagename(self.path_info)
 
@@ -1408,6 +1410,9 @@
         Delete circular references - all object that we create using self.name = class(self).
         This helps Python to collect these objects and keep our memory footprint lower.
         """
+        for method in self._finishers:
+            method(self)
+
         try:
             del self.user
             del self.theme
@@ -1415,6 +1420,9 @@
         except:
             pass
 
+    def add_finisher(self, method):
+        self._finishers.append(method)
+
     # Debug ------------------------------------------------------------
 
     def debugEnvironment(self, env):