diff --git a/gramps/cli/grampscli.py b/gramps/cli/grampscli.py index d1d3cfc07..d7b9afea6 100644 --- a/gramps/cli/grampscli.py +++ b/gramps/cli/grampscli.py @@ -47,6 +47,7 @@ LOG = logging.getLogger(".grampscli") from gramps.gen.display.name import displayer as name_displayer from gramps.gen.config import config from gramps.gen.const import PLUGINS_DIR, USER_PLUGINS +from gramps.gen.db.dbconst import DBBACKEND from gramps.gen.errors import DbError from gramps.gen.dbstate import DbState from gramps.gen.db.exceptions import (DbUpgradeRequiredError, @@ -151,7 +152,14 @@ class CLIDbLoader(object): else: mode = 'w' - db = self.dbstate.make_database("bsddb") + dbid_path = os.path.join(filename, DBBACKEND) + if os.path.isfile(dbid_path): + with open(dbid_path) as fp: + dbid = fp.read().strip() + else: + dbid = "bsddb" + + db = self.dbstate.make_database(dbid) self.dbstate.change_database(db) self.dbstate.db.disable_signals() diff --git a/gramps/gui/dbloader.py b/gramps/gui/dbloader.py index f3d303b15..d95c6bb9a 100644 --- a/gramps/gui/dbloader.py +++ b/gramps/gui/dbloader.py @@ -52,6 +52,7 @@ from gi.repository import GObject # #------------------------------------------------------------------------- from gramps.gen.const import GRAMPS_LOCALE as glocale +from gramps.gen.db.dbconst import DBBACKEND _ = glocale.translation.gettext from gramps.cli.grampscli import CLIDbLoader from gramps.gen.config import config @@ -304,7 +305,14 @@ class DbLoader(CLIDbLoader): else: mode = 'w' - db = self.dbstate.make_database("bsddb") + dbid_path = os.path.join(filename, DBBACKEND) + if os.path.isfile(dbid_path): + with open(dbid_path) as fp: + dbid = fp.read().strip() + else: + dbid = "bsddb" + + db = self.dbstate.make_database(dbid) db.disable_signals() self.dbstate.no_database() diff --git a/gramps/plugins/database/djangodb.py b/gramps/plugins/database/djangodb.py index adb28dc54..e0d8c043a 100644 --- a/gramps/plugins/database/djangodb.py +++ b/gramps/plugins/database/djangodb.py @@ -55,6 +55,11 @@ from gramps.gen.db import (PERSON_KEY, from gramps.gen.utils.id import create_id from django.db import transaction +## add this directory to sys path, so we can find django_support later: +import sys +import os +sys.path.append(os.path.dirname(os.path.abspath(__file__))) + class Environment(object): """ Implements the Environment API. @@ -322,10 +327,15 @@ class DbDjango(DbWriteBase, DbReadBase, UpdateCallback, Callback): if directory: self.load(directory) - def load(self, directory, pulse_progress=None, mode=None): + def load(self, directory, pulse_progress=None, mode=None, + force_schema_upgrade=False, + force_bsddb_upgrade=False, + force_bsddb_downgrade=False, + force_python_upgrade=False): self._directory = directory from django.conf import settings - default_settings = {} + default_settings = {"__file__": + os.path.join(directory, "default_settings.py")} settings_file = os.path.join(directory, "default_settings.py") with open(settings_file) as f: code = compile(f.read(), settings_file, 'exec') @@ -1785,7 +1795,10 @@ class DbDjango(DbWriteBase, DbReadBase, UpdateCallback, Callback): return self.family_bookmarks def get_save_path(self): - return "/tmp/" + return self._directory + + def set_save_path(self, directory): + self._directory = directory ## Get types: def get_event_attribute_types(self):