From fcef732f9394fad0014c14c6e2f6fc7cdaac3df0 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Sat, 21 Aug 2010 20:20:34 +0000 Subject: [PATCH] Added dbid and dbname to databases; id is the unique dir name, and name is the assigned name stored in text file svn: r15786 --- src/gen/db/base.py | 12 ++++++++++++ src/gen/db/read.py | 13 +++++++++++++ src/gen/db/write.py | 18 +++++++++++++++++- src/gui/viewmanager.py | 4 ++-- 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/gen/db/base.py b/src/gen/db/base.py index 257785ea0..884145b8e 100644 --- a/src/gen/db/base.py +++ b/src/gen/db/base.py @@ -1055,6 +1055,18 @@ class DbReadBase(object): """ raise NotImplementedError + def get_dbid(self): + """ + A unique ID for this database on this computer. + """ + raise NotImplementedError + + def get_dbname(self): + """ + A name for this database on this computer. + """ + raise NotImplementedError + class DbWriteBase(object): """ GRAMPS database object. This object is a base class for all diff --git a/src/gen/db/read.py b/src/gen/db/read.py index 056042611..7769b3f67 100644 --- a/src/gen/db/read.py +++ b/src/gen/db/read.py @@ -1466,3 +1466,16 @@ class DbBsddbRead(DbReadBase, Callback): """ return self._bm_changes > 0 + def get_dbid(self): + """ + In BSDDB, we use the file directory name as the unique ID for + this database on this computer. + """ + return None + + def get_dbname(self): + """ + In BSDDB, a database's name is not known until after we open it. + """ + return None + diff --git a/src/gen/db/write.py b/src/gen/db/write.py index e3be0325f..7f09a0475 100644 --- a/src/gen/db/write.py +++ b/src/gen/db/write.py @@ -206,6 +206,8 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback): #UpdateCallback.__init__(self) self.secondary_connected = False self.has_changed = False + self.brief_name = None + self.db_name = None def catch_db_error(func): """ @@ -1715,7 +1717,21 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback): self.metadata.close() self.env.close() - + + def get_dbid(self): + """ + In BSDDB, we use the file directory name as the unique ID for + this database on this computer. + """ + return self.brief_name + + def get_dbname(self): + """ + In BSDDB, we use the file directory name as the unique ID for + this database on this computer. + """ + return self.db_name + #------------------------------------------------------------------------- # # BdbTransaction diff --git a/src/gui/viewmanager.py b/src/gui/viewmanager.py index 88da37bc8..5396cb38a 100644 --- a/src/gui/viewmanager.py +++ b/src/gui/viewmanager.py @@ -1209,7 +1209,7 @@ class ViewManager(CLIManager): if filename[-1] == os.path.sep: filename = filename[:-1] name = os.path.basename(filename) - self.db_name = title + self.dbstate.db.db_name = title if title: name = title @@ -1328,7 +1328,7 @@ class ViewManager(CLIManager): hbox.pack_start(label, False) struct_time = time.localtime() file_entry.set_text(config.get('paths.quick-backup-filename') % - {"filename": self.db_name, + {"filename": self.dbstate.db.get_dbname(), "year": struct_time.tm_year, "month": struct_time.tm_mon, "day": struct_time.tm_mday,