Commit 6fcc4daa authored by Jeremy Hylton's avatar Jeremy Hylton

Cleanup __del__.

You never need an __del__ to close a file.  A file closes itself when
it is deallocated.

Don't give an object a magic __del__ attribute.  It won't work with
new-style classes, and it's obscure anyway.
parent 61cbc091
......@@ -37,10 +37,6 @@ class TmpStore:
self._db = None
self._creating = []
def __del__(self):
# XXX Is this necessary?
self._file.close()
def close(self):
self._file.close()
......
......@@ -16,7 +16,7 @@
This module provides a wrapper that causes a database connection to be created
and used when bobo publishes a bobo_application object.
"""
__version__='$Revision: 1.12 $'[11:-2]
__version__='$Revision: 1.13 $'[11:-2]
StringType=type('')
connection_open_hooks = []
......@@ -52,8 +52,7 @@ class ZApplicationWrapper:
hook(conn)
# arrange for the connection to be closed when the request goes away
cleanup=Cleanup()
cleanup.__del__=conn.close
cleanup = Cleanup(conn)
REQUEST._hold(cleanup)
conn.setDebugInfo(REQUEST.environ, REQUEST.other)
......@@ -81,4 +80,9 @@ class ZApplicationWrapper:
return connection.root()[aname]
class Cleanup: pass
class Cleanup:
def __init__(self, jar):
self._jar = jar
def __del__(self):
self._jar.close()
......@@ -69,6 +69,3 @@ class LockFile:
self._fp.close()
os.unlink(self._path)
self._fp = None
def __del__(self):
self.close()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment