Commit fae74fa5 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 032d309c
...@@ -37,10 +37,6 @@ class TmpStore: ...@@ -37,10 +37,6 @@ class TmpStore:
self._db = None self._db = None
self._creating = [] self._creating = []
def __del__(self):
# XXX Is this necessary?
self._file.close()
def close(self): def close(self):
self._file.close() self._file.close()
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
This module provides a wrapper that causes a database connection to be created This module provides a wrapper that causes a database connection to be created
and used when bobo publishes a bobo_application object. and used when bobo publishes a bobo_application object.
""" """
__version__='$Revision: 1.12 $'[11:-2] __version__='$Revision: 1.13 $'[11:-2]
StringType=type('') StringType=type('')
connection_open_hooks = [] connection_open_hooks = []
...@@ -52,8 +52,7 @@ class ZApplicationWrapper: ...@@ -52,8 +52,7 @@ class ZApplicationWrapper:
hook(conn) hook(conn)
# arrange for the connection to be closed when the request goes away # arrange for the connection to be closed when the request goes away
cleanup=Cleanup() cleanup = Cleanup(conn)
cleanup.__del__=conn.close
REQUEST._hold(cleanup) REQUEST._hold(cleanup)
conn.setDebugInfo(REQUEST.environ, REQUEST.other) conn.setDebugInfo(REQUEST.environ, REQUEST.other)
...@@ -81,4 +80,9 @@ class ZApplicationWrapper: ...@@ -81,4 +80,9 @@ class ZApplicationWrapper:
return connection.root()[aname] 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: ...@@ -69,6 +69,3 @@ class LockFile:
self._fp.close() self._fp.close()
os.unlink(self._path) os.unlink(self._path)
self._fp = None 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