BE._open(FILE, WRITEP)
Open the existing database FILE; used by `open'.
- BE._close() Close the database, freeing up any resources.
+ BE._close(ABRUPTP) Close the database, freeing up any resources. If
+ ABRUPTP then don't try to commit changes.
BE._get_meta(NAME, DEFAULT)
Return the value of the metadata item with the given
me._writep = writep
me._livep = True
- def close(me):
+ def close(me, abruptp = False):
"""
Close the database.
"""
if me._livep:
me._livep = False
- me._close()
+ me._close(abruptp)
## Utilities.
return me
def __exit__(me, exctype, excvalue, exctb):
"""Context protocol: see `__enter__'."""
- me.close()
+ me.close(excvalue is not None)
## Metadata.
def _create(me, file):
me._db = _G.open(file, 'n', 0600)
- def _close(me):
+ def _close(me, abruptp):
me._db.close()
me._db = None
def __enter__(me):
return me
def __exit__(me, excty, excval, exctb):
- me.db.close()
+ me.db.close(excval is not None)
###----- That's all, folks --------------------------------------------------