Remove write_version method from the database API
This is specific to the BSDDB backend.
This commit is contained in:
@@ -504,7 +504,6 @@ class ArgHandler:
|
|||||||
self.imp_db_path = get_empty_tempdir("import_dbdir")
|
self.imp_db_path = get_empty_tempdir("import_dbdir")
|
||||||
dbid = config.get('database.backend')
|
dbid = config.get('database.backend')
|
||||||
newdb = make_database(dbid)
|
newdb = make_database(dbid)
|
||||||
newdb.write_version(self.imp_db_path)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.smgr.open_activate(self.imp_db_path, self.username, self.password)
|
self.smgr.open_activate(self.imp_db_path, self.username, self.password)
|
||||||
|
@@ -68,6 +68,7 @@ _LOG = logging.getLogger(DBLOGNAME)
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
DEFAULT_TITLE = _("Family Tree")
|
DEFAULT_TITLE = _("Family Tree")
|
||||||
NAME_FILE = "name.txt"
|
NAME_FILE = "name.txt"
|
||||||
|
BACKEND_FILE = "database.txt"
|
||||||
META_NAME = "meta_data.db"
|
META_NAME = "meta_data.db"
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@@ -306,8 +307,10 @@ class CLIDbManager:
|
|||||||
if dbid is None:
|
if dbid is None:
|
||||||
dbid = config.get('database.backend')
|
dbid = config.get('database.backend')
|
||||||
newdb = make_database(dbid)
|
newdb = make_database(dbid)
|
||||||
# write the version number into metadata
|
|
||||||
newdb.write_version(new_path)
|
backend_path = os.path.join(new_path, BACKEND_FILE)
|
||||||
|
with open(backend_path, "w", encoding='utf8') as backend_file:
|
||||||
|
backend_file.write(dbid)
|
||||||
|
|
||||||
(tval, last) = time_val(new_path)
|
(tval, last) = time_val(new_path)
|
||||||
|
|
||||||
|
@@ -1797,12 +1797,6 @@ class DbWriteBase(DbReadBase):
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def write_version(self, name):
|
|
||||||
"""
|
|
||||||
Write version number for a newly created DB.
|
|
||||||
"""
|
|
||||||
raise NotImplementedError
|
|
||||||
|
|
||||||
def add_child_to_family(self, family, child,
|
def add_child_to_family(self, family, child,
|
||||||
mrel=ChildRefType(),
|
mrel=ChildRefType(),
|
||||||
frel=ChildRefType(),
|
frel=ChildRefType(),
|
||||||
|
@@ -60,7 +60,6 @@ class FileTest(unittest.TestCase):
|
|||||||
# Create database
|
# Create database
|
||||||
db = make_database("bsddb")
|
db = make_database("bsddb")
|
||||||
path = get_empty_tempdir("utils_file_test")
|
path = get_empty_tempdir("utils_file_test")
|
||||||
db.write_version(path)
|
|
||||||
db.load(path)
|
db.load(path)
|
||||||
|
|
||||||
# Test without db.mediapath set
|
# Test without db.mediapath set
|
||||||
|
@@ -929,9 +929,6 @@ class DbManager(CLIDbManager, ManagedWindow):
|
|||||||
fname = os.path.join(dirname, filename)
|
fname = os.path.join(dirname, filename)
|
||||||
os.unlink(fname)
|
os.unlink(fname)
|
||||||
|
|
||||||
newdb = make_database("bsddb")
|
|
||||||
newdb.write_version(dirname)
|
|
||||||
|
|
||||||
dbase = make_database("bsddb")
|
dbase = make_database("bsddb")
|
||||||
dbase.load(dirname, None)
|
dbase.load(dirname, None)
|
||||||
|
|
||||||
|
@@ -62,7 +62,6 @@ class TestEditReference(unittest.TestCase):
|
|||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
db.write_version(path)
|
|
||||||
db.load(path)
|
db.load(path)
|
||||||
dbstate.change_database(db)
|
dbstate.change_database(db)
|
||||||
source = Place()
|
source = Place()
|
||||||
|
@@ -207,7 +207,6 @@ class DbTest(unittest.TestCase):
|
|||||||
"set_name_group_mapping",
|
"set_name_group_mapping",
|
||||||
"transaction_begin",
|
"transaction_begin",
|
||||||
"transaction_commit",
|
"transaction_commit",
|
||||||
"write_version",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
def _verify_readonly(self, db):
|
def _verify_readonly(self, db):
|
||||||
|
@@ -562,6 +562,11 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
|||||||
self.path = self.full_name
|
self.path = self.full_name
|
||||||
self.brief_name = os.path.basename(name)
|
self.brief_name = os.path.basename(name)
|
||||||
|
|
||||||
|
# We use the existence of the person table as a proxy for the database
|
||||||
|
# being new
|
||||||
|
if not os.path.exists(os.path.join(self.path, 'person.db')):
|
||||||
|
self._write_version(name)
|
||||||
|
|
||||||
# If we re-enter load with force_python_upgrade True, then we have
|
# If we re-enter load with force_python_upgrade True, then we have
|
||||||
# already checked the bsddb version, and then checked python version,
|
# already checked the bsddb version, and then checked python version,
|
||||||
# and are agreeing on the upgrade
|
# and are agreeing on the upgrade
|
||||||
@@ -2200,7 +2205,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
|||||||
else:
|
else:
|
||||||
_LOG.debug("Failed to set autoremove flag")
|
_LOG.debug("Failed to set autoremove flag")
|
||||||
|
|
||||||
def write_version(self, name):
|
def _write_version(self, name):
|
||||||
"""Write version number for a newly created DB."""
|
"""Write version number for a newly created DB."""
|
||||||
full_name = os.path.abspath(name)
|
full_name = os.path.abspath(name)
|
||||||
|
|
||||||
@@ -2258,11 +2263,6 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
|||||||
version = str(_DBVERSION)
|
version = str(_DBVERSION)
|
||||||
version_file.write(version)
|
version_file.write(version)
|
||||||
|
|
||||||
versionpath = os.path.join(name, str(DBBACKEND))
|
|
||||||
_LOG.debug("Write database backend file to 'bsddb'")
|
|
||||||
with open(versionpath, "w") as version_file:
|
|
||||||
version_file.write("bsddb")
|
|
||||||
|
|
||||||
self.metadata.close()
|
self.metadata.close()
|
||||||
self.env.close()
|
self.env.close()
|
||||||
|
|
||||||
|
@@ -53,13 +53,6 @@ class DBAPI(DbGeneric):
|
|||||||
"""
|
"""
|
||||||
Database backends class for DB-API 2.0 databases
|
Database backends class for DB-API 2.0 databases
|
||||||
"""
|
"""
|
||||||
def write_version(self, directory):
|
|
||||||
"""Write files for a newly created DB."""
|
|
||||||
versionpath = os.path.join(directory, str(DBBACKEND))
|
|
||||||
_LOG.debug("Write database backend file")
|
|
||||||
with open(versionpath, "w") as version_file:
|
|
||||||
version_file.write(self.__class__.__name__.lower())
|
|
||||||
|
|
||||||
def _initialize(self, directory, username, password):
|
def _initialize(self, directory, username, password):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user