Loads tree based on id in database.txt

This commit is contained in:
Doug Blank 2015-05-13 12:36:17 -04:00
parent 337ba6b22a
commit beb8b8e3ab
3 changed files with 34 additions and 5 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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):