[Repoze-checkins] r1223 - in repoze.zope2/trunk: . repoze/zope2 repoze/zope2/tests

Chris McDonough chrism at agendaless.com
Thu Jul 3 20:36:19 EDT 2008


Author: Chris McDonough <chrism at agendaless.com>
Date: Thu Jul  3 20:36:19 2008
New Revision: 1223

Log:
  - During helper teardown, clear out reference to request.response,
    so in case the request is leaked, the tempfile associated with the
    response isn't.



Modified:
   repoze.zope2/trunk/CHANGES.txt
   repoze.zope2/trunk/repoze/zope2/tests/test_z2bob.py
   repoze.zope2/trunk/repoze/zope2/z2bob.py
   repoze.zope2/trunk/setup.py

Modified: repoze.zope2/trunk/CHANGES.txt
==============================================================================
--- repoze.zope2/trunk/CHANGES.txt	(original)
+++ repoze.zope2/trunk/CHANGES.txt	Thu Jul  3 20:36:19 2008
@@ -1,3 +1,9 @@
+0.4.6 (2008-07-03)
+
+  - During helper teardown, clear out reference to request.response,
+    so in case the request is leaked, the tempfile associated with the
+    response isn't.
+
 0.4.5 (2008-06-26)
 
   - Make disable_gc only happen at initialization.  Drool.

Modified: repoze.zope2/trunk/repoze/zope2/tests/test_z2bob.py
==============================================================================
--- repoze.zope2/trunk/repoze/zope2/tests/test_z2bob.py	(original)
+++ repoze.zope2/trunk/repoze/zope2/tests/test_z2bob.py	Thu Jul  3 20:36:19 2008
@@ -276,6 +276,7 @@
         self.assertEqual(queryInteraction(), None)
         self.assertEqual(request.closed, True)
         self.assertEqual(_managers,{}) # noSecurityManager called
+        self.assertEqual(request.response, None) # explicitly cleared
         self.assertEqual(helper.request, None)
         self.assertEqual(helper.user_folders, None)
         self.assertEqual(helper.vroot_stack, None)

Modified: repoze.zope2/trunk/repoze/zope2/z2bob.py
==============================================================================
--- repoze.zope2/trunk/repoze/zope2/z2bob.py	(original)
+++ repoze.zope2/trunk/repoze/zope2/z2bob.py	Thu Jul  3 20:36:19 2008
@@ -220,6 +220,10 @@
         if self.request is not None:
             # if there was not an error during setup()
             self.request.close()
+            # get rid of reference to response in case the request is leaked
+            # because a RepozeHTTPResponse holds on to a NamedTemporaryFile.
+            self.request.response = None 
+
         # It's very important to call noSecurityManager() here;
         # otherwise we'll leak as many references to AccessControl
         # SecurityManager objects as there are threads in the WSGI
@@ -231,10 +235,11 @@
         # security manager now to avoid a leak.  In fact, the call in
         # setup() is probably voodoo.
         noSecurityManager() 
-        # Be explicit about clearing out references; if we hang around
-        # for some reason, we don't want our subitems hanging around.
-        # But we can't yet get rid of environ or conn as they're used
-        # in __del__ :-(
+
+        # Be tediously explicit about clearing out references; if we
+        # get leaked for some reason, we really don't want our
+        # subitems hanging around.  But we can't yet get rid of
+        # environ or conn as they're used in __del__ :-(
         self.request = None
         self.user_folders = None
         self.vroot_stack = None

Modified: repoze.zope2/trunk/setup.py
==============================================================================
--- repoze.zope2/trunk/setup.py	(original)
+++ repoze.zope2/trunk/setup.py	Thu Jul  3 20:36:19 2008
@@ -12,7 +12,7 @@
 #
 ##############################################################################
 
-__version__ = '0.4.5'
+__version__ = '0.4.6'
 
 from ez_setup import use_setuptools
 use_setuptools()


More information about the Repoze-checkins mailing list