Added dbid and dbname to databases; id is the unique dir name, and name is the assigned name stored in text file

svn: r15786
This commit is contained in:
Doug Blank 2010-08-21 20:20:34 +00:00
parent 1b884b129d
commit fcef732f93
4 changed files with 44 additions and 3 deletions

View File

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

View File

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

View File

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

View File

@ -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,