diff --git a/src/GrampsAboutDialog.py b/src/GrampsAboutDialog.py index 7912e12b6..ded69b8ad 100644 --- a/src/GrampsAboutDialog.py +++ b/src/GrampsAboutDialog.py @@ -30,7 +30,6 @@ from gen.ggettext import gettext as _ import os import sys -import bsddb ##import logging ##_LOG = logging.getLogger(".GrampsAboutDialog") @@ -54,6 +53,12 @@ import gtk #------------------------------------------------------------------------- import const from GrampsDisplay import url as display_url +import config + +if config.get('preferences.use-bsddb3'): + import bsddb3 as bsddb +else: + import bsddb #------------------------------------------------------------------------- # diff --git a/src/GrampsLogger/_ErrorReportAssistant.py b/src/GrampsLogger/_ErrorReportAssistant.py index 2c4a5ad59..33d846d99 100644 --- a/src/GrampsLogger/_ErrorReportAssistant.py +++ b/src/GrampsLogger/_ErrorReportAssistant.py @@ -5,8 +5,13 @@ import gtk import pygtk import gobject import cairo -import sys, os,bsddb +import sys, os +import config +if config.get('preferences.use-bsddb3'): + import bsddb3 as bsddb +else: + import bsddb class ErrorReportAssistant(object): diff --git a/src/cli/clidbman.py b/src/cli/clidbman.py index 629ee31d7..a0b1ab612 100644 --- a/src/cli/clidbman.py +++ b/src/cli/clidbman.py @@ -108,7 +108,10 @@ class CLIDbManager(object): Returns (people_count, version_number) of current DB. Returns ("Unknown", "Unknown") if invalid DB or other error. """ - from bsddb import dbshelve, db + if config.get('preferences.use-bsddb3'): + from bsddb3 import dbshelve, db + else: + from bsddb import dbshelve, db from gen.db import META, PERSON_TBL env = db.DBEnv() flags = db.DB_CREATE | db.DB_PRIVATE |\ diff --git a/src/config.py b/src/config.py index 3ae28a229..7f718b63a 100644 --- a/src/config.py +++ b/src/config.py @@ -288,6 +288,7 @@ register('preferences.sprefix', 'S%04d') register('preferences.use-last-view', True) register('preferences.last-view', '') register('preferences.last-views', []) +register('preferences.use-bsddb3', False) register('researcher.researcher-addr', '') register('researcher.researcher-locality', '') diff --git a/src/gen/db/bsddbtxn.py b/src/gen/db/bsddbtxn.py index ec315745a..114da01fd 100644 --- a/src/gen/db/bsddbtxn.py +++ b/src/gen/db/bsddbtxn.py @@ -188,7 +188,11 @@ class BSDDBTxn(object): # test code if __name__ == "__main__": print "1" - from bsddb import db, dbshelve + import config + if config.get('preferences.use-bsddb3'): + from bsddb3 import db, dbshelve + else: + from bsddb import db, dbshelve print "2" x = db.DBEnv() print "3" diff --git a/src/gen/db/cursor.py b/src/gen/db/cursor.py index 113f701ba..8a4d8c6f0 100644 --- a/src/gen/db/cursor.py +++ b/src/gen/db/cursor.py @@ -24,7 +24,12 @@ # #------------------------------------------------------------------------- from cPickle import dumps, loads -from bsddb import db + +import config +if config.get('preferences.use-bsddb3'): + from bsddb3 import db +else: + from bsddb import db #------------------------------------------------------------------------- # diff --git a/src/gen/db/dbconst.py b/src/gen/db/dbconst.py index 8e3635751..b9540804f 100644 --- a/src/gen/db/dbconst.py +++ b/src/gen/db/dbconst.py @@ -63,7 +63,11 @@ DBLOCKS = 25000 # Maximum number of locks supported DBOBJECTS = 25000 # Maximum number of simultaneously locked objects DBUNDO = 1000 # Maximum size of undo buffer -from bsddb.db import DB_CREATE, DB_AUTO_COMMIT, DB_DUP, DB_DUPSORT, DB_RDONLY +import config +if config.get('preferences.use-bsddb3'): + from bsddb3.db import DB_CREATE, DB_AUTO_COMMIT, DB_DUP, DB_DUPSORT, DB_RDONLY +else: + from bsddb.db import DB_CREATE, DB_AUTO_COMMIT, DB_DUP, DB_DUPSORT, DB_RDONLY DBFLAGS_O = DB_CREATE | DB_AUTO_COMMIT # Default flags for database open DBFLAGS_R = DB_RDONLY # Flags to open a database read-only DBFLAGS_D = DB_DUP | DB_DUPSORT # Default flags for duplicate keys diff --git a/src/gen/db/read.py b/src/gen/db/read.py index e3bf4f049..522bcbc72 100644 --- a/src/gen/db/read.py +++ b/src/gen/db/read.py @@ -36,7 +36,12 @@ import random import locale import os from sys import maxint -from bsddb import db + +import config +if config.get('preferences.use-bsddb3'): + from bsddb3 import db +else: + from bsddb import db from gen.ggettext import gettext as _ import logging diff --git a/src/gen/db/txn.py b/src/gen/db/txn.py index 778614a2c..186bc5d04 100644 --- a/src/gen/db/txn.py +++ b/src/gen/db/txn.py @@ -32,8 +32,14 @@ database. #------------------------------------------------------------------------- from __future__ import with_statement import cPickle as pickle -from bsddb import dbshelve, db + +import config +if config.get('preferences.use-bsddb3'): + from bsddb3 import dbshelve, db +else: + from bsddb import dbshelve, db import logging + from collections import defaultdict #------------------------------------------------------------------------- diff --git a/src/gen/db/undoredo.py b/src/gen/db/undoredo.py index 134863dd4..68ba6a711 100644 --- a/src/gen/db/undoredo.py +++ b/src/gen/db/undoredo.py @@ -33,10 +33,15 @@ undos and redos. from __future__ import with_statement import time, os import cPickle as pickle -from bsddb import db -from gen.ggettext import gettext as _ from collections import deque +import config +if config.get('preferences.use-bsddb3'): + from bsddb3 import db +else: + from bsddb import db +from gen.ggettext import gettext as _ + #------------------------------------------------------------------------- # # Gramps modules diff --git a/src/gen/db/upgrade.py b/src/gen/db/upgrade.py index bf996a847..554a9e5a6 100644 --- a/src/gen/db/upgrade.py +++ b/src/gen/db/upgrade.py @@ -29,7 +29,11 @@ import time """ methods to upgrade a database from version 13 to current version """ -from bsddb import db +import config +if config.get('preferences.use-bsddb3'): + from bsddb3 import db +else: + from bsddb import db from gen.db import BSDDBTxn from gen.lib.nameorigintype import NameOriginType from gen.db.write import _mkname, SURNAMES diff --git a/src/gen/db/write.py b/src/gen/db/write.py index 381a038c2..0207a24a0 100644 --- a/src/gen/db/write.py +++ b/src/gen/db/write.py @@ -38,12 +38,16 @@ import time import locale import bisect from functools import wraps - -from gen.ggettext import gettext as _ -from bsddb import dbshelve, db import logging from sys import maxint +from gen.ggettext import gettext as _ +import config +if config.get('preferences.use-bsddb3'): + from bsddb3 import dbshelve, db +else: + from bsddb import dbshelve, db + #------------------------------------------------------------------------- # # Gramps modules @@ -413,6 +417,10 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback): except: pass raise DbEnvironmentError(msg) + # Set not to flush to disk synchronous + self.env.set_flags(db.DB_TXN_NOSYNC, 1) + self.env.set_flags(db.DB_TXN_WRITE_NOSYNC, 1) + self.env.txn_checkpoint() if callback: @@ -1636,8 +1644,8 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback): self.undodb.clear() self.env.txn_checkpoint() - if db.version() < (4, 7): - 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 no_magic: # Disconnect unneeded secondary indices @@ -1676,8 +1684,8 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback): """ if transaction.batch: self.env.txn_checkpoint() - if db.version() < (4, 7): - 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 diff --git a/src/gen/plug/_gramplet.py b/src/gen/plug/_gramplet.py index a0c0afb63..d4bca90c3 100644 --- a/src/gen/plug/_gramplet.py +++ b/src/gen/plug/_gramplet.py @@ -21,7 +21,11 @@ # $Id$ -import bsddb +import config +if config.get('preferences.use-bsddb3'): + import bsddb3 as bsddb +else: + import bsddb import types from gen.ggettext import gettext as _ diff --git a/src/gramps.py b/src/gramps.py index cfc15d5d8..0ff0327c9 100644 --- a/src/gramps.py +++ b/src/gramps.py @@ -191,11 +191,18 @@ def show_settings(): except ImportError: cairover_str = 'not found' + import config + usebsddb3 = config.get('preferences.use-bsddb3') try: - import bsddb + if usebsddb3: + import bsddb3 as bsddb + else: + import bsddb bsddb_str = bsddb.__version__ + bsddb_db_str = str(bsddb.db.version()) except: bsddb_str = 'not found' + bsddb_db_str = 'not found' try: import const @@ -243,6 +250,7 @@ def show_settings(): print ' pygtk : %s' % pygtkver_str print ' gobject : %s' % gobjectver_str print ' bsddb : %s' % bsddb_str + print ' bsddb.db : %s' % bsddb_db_str print ' cairo : %s' % cairover_str print ' o.s. : %s' % operating_system if kernel: @@ -302,9 +310,13 @@ def run(): argpars = ArgParser(sys.argv) if argpars.need_gui(): - #A GUI is needed, set it up - from gui.grampsgui import startgtkloop - startgtkloop(error, argpars) + #A GUI is needed, set it up + if "--qml" in sys.argv: + from guiQML.grampsqml import startqml + startqml(error, argpars) + else: + from gui.grampsgui import startgtkloop + startgtkloop(error, argpars) else: #CLI use of GRAMPS argpars.print_help() diff --git a/src/plugins/import/ImportGrdb.py b/src/plugins/import/ImportGrdb.py index f14c64553..fffe37dfe 100644 --- a/src/plugins/import/ImportGrdb.py +++ b/src/plugins/import/ImportGrdb.py @@ -36,7 +36,12 @@ import tempfile from gen.ggettext import gettext as _ import cPickle as pickle import time -from bsddb import dbshelve, db + +import config +if config.get('preferences.use-bsddb3'): + from bsddb3 import dbshelve, db +else: + from bsddb import dbshelve, db import logging LOG = logging.getLogger(".Db") diff --git a/src/plugins/import/ImportXml.py b/src/plugins/import/ImportXml.py index 16a07cdd4..100fdf69c 100644 --- a/src/plugins/import/ImportXml.py +++ b/src/plugins/import/ImportXml.py @@ -86,6 +86,8 @@ EVENT_PERSON_STR = _("%(event_name)s of %(person)s") # #------------------------------------------------------------------------- def importData(database, filename, callback=None, cl=0): +## return Utils.profile(importDataPro, database, filename, callback, cl) +##def importDataPro(database, filename, callback=None, cl=0): if DbMixin not in database.__class__.__bases__: database.__class__.__bases__ = (DbMixin,) + \ diff --git a/src/plugins/lib/libgrdb.py b/src/plugins/lib/libgrdb.py index e165380de..24ec0cebe 100644 --- a/src/plugins/lib/libgrdb.py +++ b/src/plugins/lib/libgrdb.py @@ -36,7 +36,11 @@ import random import locale import os from sys import maxint -from bsddb import db +import config +if config.get('preferences.use-bsddb3'): + from bsddb3 import db +else: + from bsddb import db from gen.ggettext import gettext as _ import logging diff --git a/src/plugins/tool/Leak.py b/src/plugins/tool/Leak.py index e351975fa..68bd312d4 100644 --- a/src/plugins/tool/Leak.py +++ b/src/plugins/tool/Leak.py @@ -32,7 +32,11 @@ Show uncollected objects in a window. # #------------------------------------------------------------------------ from gen.ggettext import gettext as _ -from bsddb.db import DBError +import config +if config.get('preferences.use-bsddb3'): + from bsddb3.db import DBError +else: + from bsddb.db import DBError #------------------------------------------------------------------------ #