Allow to be used without bsddb installed, for uses where it is not needed (webapp and other uses)

svn: r23371
This commit is contained in:
Doug Blank 2013-10-23 02:00:38 +00:00
parent 98ccbd42a3
commit e06051fa7c
6 changed files with 73 additions and 28 deletions

View File

@ -33,10 +33,20 @@ else:
from pickle import dumps, loads
from ..config import config
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
from bsddb3 import db
else:
from bsddb import db
try:
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
from bsddb3 import db
else:
from bsddb import db
except:
# FIXME: make this more abstract to deal with other backends
class db:
DB_RMW = 0
DB_FIRST = 0
DB_LAST = 0
DB_CURRENT = 0
DB_PREV = 0
DB_NEXT = 0
#-------------------------------------------------------------------------
#

View File

@ -68,13 +68,20 @@ DBOBJECTS = 100000 # Maximum number of simultaneously locked objects
DBUNDO = 1000 # Maximum size of undo buffer
from ..config import config
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
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
try:
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
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
except:
print("WARNING: no bsddb support")
# FIXME: make this more abstract to deal with other backends, or do not import
DBFLAGS_O = DB_CREATE = DB_AUTO_COMMIT = 0
DBFLAGS_R = DB_RDONLY = 0
DBFLAGS_D = DB_DUP = DB_DUPSORT = 0
PERSON_KEY = 0
FAMILY_KEY = 1

View File

@ -44,10 +44,19 @@ import os
from sys import maxsize
from ..config import config
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
from bsddb3 import db
else:
from bsddb import db
try:
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
from bsddb3 import db
else:
from bsddb import db
except:
# FIXME: make this more abstract to deal with other backends
class db:
DBRunRecoveryError = 0
DBAccessError = 0
DBPageNotFoundError = 0
DBInvalidArgError = 0
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
import re

View File

@ -42,10 +42,19 @@ else:
from collections import deque
from ..config import config
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
from bsddb3 import db
else:
from bsddb import db
try:
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
from bsddb3 import db
else:
from bsddb import db
except:
# FIXME: make this more abstract to deal with other backends
class db:
DBRunRecoveryError = 0
DBAccessError = 0
DBPageNotFoundError = 0
DBInvalidArgError = 0
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext

View File

@ -46,10 +46,19 @@ import logging
from sys import maxsize, getfilesystemencoding, version_info
from ..config import config
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
from bsddb3 import dbshelve, db
else:
from bsddb import dbshelve, db
try:
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
from bsddb3 import dbshelve, db
else:
from bsddb import dbshelve, db
except:
# FIXME: make this more abstract to deal with other backends
class db:
DB_HASH = 0
DBRunRecoveryError = 0
DBAccessError = 0
DBPageNotFoundError = 0
DBInvalidArgError = 0
#-------------------------------------------------------------------------
#

View File

@ -24,11 +24,6 @@
from __future__ import print_function
import sys
from ..config import config
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
import bsddb3 as bsddb
else:
import bsddb
import types
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
@ -310,6 +305,12 @@ class Gramplet(object):
self._idle_id = 0
LOG.debug("gramplet updater: %s : One time, done!" % self.gui.title)
return False
# FIXME: find out why Data Entry has this error, or just ignore it
from ..config import config
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
import bsddb3 as bsddb
else:
import bsddb
try:
retval = next(self._generator)
if not retval: