[SQL-CVS] SQLObject/SQLObject DBConnection.py,1.37,1.38
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <ian...@us...> - 2003-07-10 19:39:02
|
Update of /cvsroot/sqlobject/SQLObject/SQLObject In directory sc8-pr-cvs1:/tmp/cvs-serv28749/SQLObject Modified Files: DBConnection.py Log Message: Added close method to DBMConnection, run that on __del__ or atexit. Without the close, .db files are not written with new information. Index: DBConnection.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/DBConnection.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** DBConnection.py 30 Jun 2003 22:43:06 -0000 1.37 --- DBConnection.py 10 Jul 2003 19:01:27 -0000 1.38 *************** *** 31,34 **** --- 31,35 ---- import re import warnings + import atexit warnings.filterwarnings("ignore", "DB-API extension cursor.lastrowid used") *************** *** 705,708 **** --- 706,711 ---- self._meta = anydbm.open(os.path.join(path, "meta.db"), "c") self._tables = {} + atexit.register(self.close) + self._closed = 0 FileConnection.__init__(self, **kw) *************** *** 726,729 **** --- 729,746 ---- self._tables[table] = db return db + + def close(self): + if self._closed: + return + self._closed = 1 + self._meta.close() + del self._meta + for table in self._tables.values(): + table.close() + del self._tables + + def __del__(self): + FileConnection.__del__(self) + self.close() def _openTable(self, table): |