Rewrote autoremove flag workaround

svn: r15795
This commit is contained in:
Doug Blank 2010-08-22 06:33:06 +00:00
parent c14fbafd25
commit 7151e07d3a

View File

@ -1589,8 +1589,8 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
@catch_db_error @catch_db_error
def transaction_commit(self, transaction, msg): def transaction_commit(self, transaction, msg):
if self._LOG_ALL: if self._LOG_ALL:
LOG.debug("%s: Transaction commit '%s'\n" _LOG.debug("%s: Transaction commit '%s'\n"
% (self.__class__.__name__, str(msg))) % (self.__class__.__name__, str(msg)))
if self.readonly: if self.readonly:
return return
@ -1662,25 +1662,20 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
""" """
BSDDB change log settings using new method with renamed attributes BSDDB change log settings using new method with renamed attributes
""" """
if db.version() < (4, 7): autoremove_flag = None
# by the book: old method with old attribute autoremove_method = None
self.env.set_flags(db.DB_LOG_AUTOREMOVE, 1) for flag in ["DB_LOG_AUTO_REMOVE", "DB_LOG_AUTOREMOVE"]:
else: # look at python interface if hasattr(db, flag):
# TODO test with new version of pybsddb autoremove_flag = getattr(db, flag)
try: break
# try numeric compare, just first 2 digits for method in ["log_set_config", "set_flags"]:
# this won't work with something like "4.10a", but if hasattr(self.env, method):
# hopefully they won't do that autoremove_method = getattr(self.env, method)
old_version = map(int, db.__version__.split(".",2)[:2]) < (4, 7) break
except: if autoremove_method and autoremove_flag:
# fallback, weak string compare autoremove_method(autoremove_flag, 1)
old_version = db.__version__ < "4.7" else:
if old_version: _LOG.debug("Failed to set autoremove flag")
# undocumented: old method with new attribute
self.env.set_flags(db.DB_LOG_AUTO_REMOVE, 1)
else:
# by the book: new method with new attribute
self.env.log_set_config(db.DB_LOG_AUTO_REMOVE, 1)
def write_version(self, name): def write_version(self, name):
"""Write version number for a newly created DB.""" """Write version number for a newly created DB."""
@ -1702,7 +1697,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
db.DB_INIT_LOG | db.DB_INIT_TXN | db.DB_THREAD db.DB_INIT_LOG | db.DB_INIT_TXN | db.DB_THREAD
# As opposed to before, we always try recovery on databases # As opposed to before, we always try recovery on databases
env_flags = env_flags | db.DB_RECOVER env_flags |= db.DB_RECOVER
# Environment name is now based on the filename # Environment name is now based on the filename
env_name = name env_name = name