Loads tree based on id in database.txt
This commit is contained in:
parent
16a5665e3e
commit
6bff90419e
@ -47,6 +47,7 @@ LOG = logging.getLogger(".grampscli")
|
|||||||
from gramps.gen.display.name import displayer as name_displayer
|
from gramps.gen.display.name import displayer as name_displayer
|
||||||
from gramps.gen.config import config
|
from gramps.gen.config import config
|
||||||
from gramps.gen.const import PLUGINS_DIR, USER_PLUGINS
|
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.errors import DbError
|
||||||
from gramps.gen.dbstate import DbState
|
from gramps.gen.dbstate import DbState
|
||||||
from gramps.gen.db.exceptions import (DbUpgradeRequiredError,
|
from gramps.gen.db.exceptions import (DbUpgradeRequiredError,
|
||||||
@ -151,7 +152,14 @@ class CLIDbLoader(object):
|
|||||||
else:
|
else:
|
||||||
mode = 'w'
|
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.change_database(db)
|
||||||
self.dbstate.db.disable_signals()
|
self.dbstate.db.disable_signals()
|
||||||
|
@ -52,6 +52,7 @@ from gi.repository import GObject
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||||
|
from gramps.gen.db.dbconst import DBBACKEND
|
||||||
_ = glocale.translation.gettext
|
_ = glocale.translation.gettext
|
||||||
from gramps.cli.grampscli import CLIDbLoader
|
from gramps.cli.grampscli import CLIDbLoader
|
||||||
from gramps.gen.config import config
|
from gramps.gen.config import config
|
||||||
@ -304,7 +305,14 @@ class DbLoader(CLIDbLoader):
|
|||||||
else:
|
else:
|
||||||
mode = 'w'
|
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()
|
db.disable_signals()
|
||||||
self.dbstate.no_database()
|
self.dbstate.no_database()
|
||||||
|
|
||||||
|
@ -55,6 +55,11 @@ from gramps.gen.db import (PERSON_KEY,
|
|||||||
from gramps.gen.utils.id import create_id
|
from gramps.gen.utils.id import create_id
|
||||||
from django.db import transaction
|
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):
|
class Environment(object):
|
||||||
"""
|
"""
|
||||||
Implements the Environment API.
|
Implements the Environment API.
|
||||||
@ -322,10 +327,15 @@ class DbDjango(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
if directory:
|
if directory:
|
||||||
self.load(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
|
self._directory = directory
|
||||||
from django.conf import settings
|
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")
|
settings_file = os.path.join(directory, "default_settings.py")
|
||||||
with open(settings_file) as f:
|
with open(settings_file) as f:
|
||||||
code = compile(f.read(), settings_file, 'exec')
|
code = compile(f.read(), settings_file, 'exec')
|
||||||
@ -1785,7 +1795,10 @@ class DbDjango(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
return self.family_bookmarks
|
return self.family_bookmarks
|
||||||
|
|
||||||
def get_save_path(self):
|
def get_save_path(self):
|
||||||
return "/tmp/"
|
return self._directory
|
||||||
|
|
||||||
|
def set_save_path(self, directory):
|
||||||
|
self._directory = directory
|
||||||
|
|
||||||
## Get types:
|
## Get types:
|
||||||
def get_event_attribute_types(self):
|
def get_event_attribute_types(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user