backport to suppport bsddb 4.7 / python 2.6
svn: r11391
This commit is contained in:
parent
677af32e5e
commit
663b2aead9
@ -337,7 +337,8 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
||||
# These env settings are only needed for Txn environment
|
||||
self.env.set_lk_max_locks(25000)
|
||||
self.env.set_lk_max_objects(25000)
|
||||
self.env.set_flags(db.DB_LOG_AUTOREMOVE,1) # clean up unused logs
|
||||
|
||||
self.set_auto_remove()
|
||||
|
||||
# The DB_PRIVATE flag must go if we ever move to multi-user setup
|
||||
env_flags = db.DB_CREATE|db.DB_PRIVATE|\
|
||||
@ -1386,7 +1387,8 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
||||
if transaction.batch:
|
||||
if self.UseTXN:
|
||||
self.env.txn_checkpoint()
|
||||
self.env.set_flags(db.DB_TXN_NOSYNC,1) # async txn
|
||||
if db.version() < (4, 7):
|
||||
self.env.set_flags(db.DB_TXN_NOSYNC, 1) # async txn
|
||||
|
||||
if self.secondary_connected and not transaction.no_magic:
|
||||
# Disconnect unneeded secondary indices
|
||||
@ -1426,7 +1428,8 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
||||
if transaction.batch:
|
||||
if self.UseTXN:
|
||||
self.env.txn_checkpoint()
|
||||
self.env.set_flags(db.DB_TXN_NOSYNC,0) # sync txn
|
||||
if db.version() < (4, 7):
|
||||
self.env.set_flags(db.DB_TXN_NOSYNC, 0) # sync txn
|
||||
|
||||
if not transaction.no_magic:
|
||||
# create new secondary indices to replace the ones removed
|
||||
@ -1498,6 +1501,31 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
||||
db_map.put(handle,data,txn=self.txn)
|
||||
self.emit(signal,([handle],))
|
||||
|
||||
def set_auto_remove(self):
|
||||
"""
|
||||
BSDDB change log settings using new method with renamed attributes
|
||||
"""
|
||||
if db.version() < (4, 7):
|
||||
# by the book: old method with old attribute
|
||||
self.env.set_flags(db.DB_LOG_AUTOREMOVE, 1)
|
||||
else: # look at python pybsddb interface, should also be 4.7+
|
||||
# TODO test with new version of pybsddb
|
||||
try:
|
||||
# try numeric compare, just first 2 digits
|
||||
# this won't work with something like "4.10a", but
|
||||
# hopefully they won't do that
|
||||
old_version = map(int, db.__version__.split(".",2)[:2]) < (4, 7)
|
||||
except:
|
||||
# fallback, weak string compare
|
||||
old_version = db.__version__ < "4.7"
|
||||
if old_version:
|
||||
# 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 gramps_upgrade(self,callback=None):
|
||||
UpdateCallback.__init__(self,callback)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user