chiark
/
gitweb
/
~mdw
/
catacomb-python
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
catacomb/pwsafe.py: Add a new ABRUPTP argument to `close' methods.
[catacomb-python]
/
catacomb
/
pwsafe.py
diff --git
a/catacomb/pwsafe.py
b/catacomb/pwsafe.py
index 44382e76056b69a0dd6d9e577885331cbc0a5d86..8b68182e098b1df3231bfa03f435fb0829bea48e 100644
(file)
--- a/
catacomb/pwsafe.py
+++ b/
catacomb/pwsafe.py
@@
-177,7
+177,8
@@
class StorageBackend (object):
BE._open(FILE, WRITEP)
Open the existing database FILE; used by `open'.
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
BE._get_meta(NAME, DEFAULT)
Return the value of the metadata item with the given
@@
-283,7
+284,7
@@
class StorageBackend (object):
me._writep = writep
me._livep = True
me._writep = writep
me._livep = True
- def close(me):
+ def close(me
, abruptp = False
):
"""
Close the database.
"""
Close the database.
@@
-292,7
+293,7
@@
class StorageBackend (object):
"""
if me._livep:
me._livep = False
"""
if me._livep:
me._livep = False
- me._close()
+ me._close(
abruptp
)
## Utilities.
## Utilities.
@@
-322,7
+323,7
@@
class StorageBackend (object):
return me
def __exit__(me, exctype, excvalue, exctb):
"""Context protocol: see `__enter__'."""
return me
def __exit__(me, exctype, excvalue, exctb):
"""Context protocol: see `__enter__'."""
- me.close()
+ me.close(
excvalue is not None
)
## Metadata.
## Metadata.
@@
-440,7
+441,7
@@
class GDBMStorageBackend (StorageBackend):
def _create(me, file):
me._db = _G.open(file, 'n', 0600)
def _create(me, file):
me._db = _G.open(file, 'n', 0600)
- def _close(me):
+ def _close(me
, abruptp
):
me._db.close()
me._db = None
me._db.close()
me._db = None
@@
-639,6
+640,6
@@
class PW (object):
def __enter__(me):
return me
def __exit__(me, excty, excval, exctb):
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 --------------------------------------------------
###----- That's all, folks --------------------------------------------------