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:
parent
98ccbd42a3
commit
e06051fa7c
@ -33,10 +33,20 @@ else:
|
|||||||
from pickle import dumps, loads
|
from pickle import dumps, loads
|
||||||
|
|
||||||
from ..config import config
|
from ..config import config
|
||||||
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
|
try:
|
||||||
from bsddb3 import db
|
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
|
||||||
else:
|
from bsddb3 import db
|
||||||
from bsddb 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
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -68,13 +68,20 @@ DBOBJECTS = 100000 # Maximum number of simultaneously locked objects
|
|||||||
DBUNDO = 1000 # Maximum size of undo buffer
|
DBUNDO = 1000 # Maximum size of undo buffer
|
||||||
|
|
||||||
from ..config import config
|
from ..config import config
|
||||||
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
|
try:
|
||||||
from bsddb3.db import DB_CREATE, DB_AUTO_COMMIT, DB_DUP, DB_DUPSORT, DB_RDONLY
|
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
|
||||||
else:
|
from bsddb3.db import DB_CREATE, DB_AUTO_COMMIT, DB_DUP, DB_DUPSORT, DB_RDONLY
|
||||||
from bsddb.db import DB_CREATE, DB_AUTO_COMMIT, DB_DUP, DB_DUPSORT, DB_RDONLY
|
else:
|
||||||
DBFLAGS_O = DB_CREATE | DB_AUTO_COMMIT # Default flags for database open
|
from bsddb.db import DB_CREATE, DB_AUTO_COMMIT, DB_DUP, DB_DUPSORT, DB_RDONLY
|
||||||
DBFLAGS_R = DB_RDONLY # Flags to open a database read-only
|
DBFLAGS_O = DB_CREATE | DB_AUTO_COMMIT # Default flags for database open
|
||||||
DBFLAGS_D = DB_DUP | DB_DUPSORT # Default flags for duplicate keys
|
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
|
PERSON_KEY = 0
|
||||||
FAMILY_KEY = 1
|
FAMILY_KEY = 1
|
||||||
|
@ -44,10 +44,19 @@ import os
|
|||||||
from sys import maxsize
|
from sys import maxsize
|
||||||
|
|
||||||
from ..config import config
|
from ..config import config
|
||||||
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
|
try:
|
||||||
from bsddb3 import db
|
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
|
||||||
else:
|
from bsddb3 import db
|
||||||
from bsddb 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
|
from ..const import GRAMPS_LOCALE as glocale
|
||||||
_ = glocale.translation.gettext
|
_ = glocale.translation.gettext
|
||||||
import re
|
import re
|
||||||
|
@ -42,10 +42,19 @@ else:
|
|||||||
from collections import deque
|
from collections import deque
|
||||||
|
|
||||||
from ..config import config
|
from ..config import config
|
||||||
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
|
try:
|
||||||
from bsddb3 import db
|
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
|
||||||
else:
|
from bsddb3 import db
|
||||||
from bsddb 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
|
from ..const import GRAMPS_LOCALE as glocale
|
||||||
_ = glocale.translation.gettext
|
_ = glocale.translation.gettext
|
||||||
|
|
||||||
|
@ -46,10 +46,19 @@ import logging
|
|||||||
from sys import maxsize, getfilesystemencoding, version_info
|
from sys import maxsize, getfilesystemencoding, version_info
|
||||||
|
|
||||||
from ..config import config
|
from ..config import config
|
||||||
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
|
try:
|
||||||
from bsddb3 import dbshelve, db
|
if config.get('preferences.use-bsddb3') or sys.version_info[0] >= 3:
|
||||||
else:
|
from bsddb3 import dbshelve, db
|
||||||
from bsddb 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
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -24,11 +24,6 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import sys
|
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
|
import types
|
||||||
from ..const import GRAMPS_LOCALE as glocale
|
from ..const import GRAMPS_LOCALE as glocale
|
||||||
_ = glocale.translation.gettext
|
_ = glocale.translation.gettext
|
||||||
@ -310,6 +305,12 @@ class Gramplet(object):
|
|||||||
self._idle_id = 0
|
self._idle_id = 0
|
||||||
LOG.debug("gramplet updater: %s : One time, done!" % self.gui.title)
|
LOG.debug("gramplet updater: %s : One time, done!" % self.gui.title)
|
||||||
return False
|
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:
|
try:
|
||||||
retval = next(self._generator)
|
retval = next(self._generator)
|
||||||
if not retval:
|
if not retval:
|
||||||
|
Loading…
Reference in New Issue
Block a user