9547: Rename some non-API database methods
This commit is contained in:
parent
7053678526
commit
ebc91f17f2
@ -121,12 +121,6 @@ class DbReadBase:
|
||||
"""
|
||||
self.__feature[feature] = value
|
||||
|
||||
def all_handles(self, table):
|
||||
"""
|
||||
Return all handles from the specified table as a list
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def close(self):
|
||||
"""
|
||||
Close the specified database.
|
||||
@ -1537,13 +1531,6 @@ class DbWriteBase(DbReadBase):
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def commit_base(self, obj, data_map, key, transaction, change_time):
|
||||
"""
|
||||
Commit the specified object to the database, storing the changes as
|
||||
part of the transaction.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def commit_event(self, event, transaction, change_time=None):
|
||||
"""
|
||||
Commit the specified Event to the database, storing the changes as
|
||||
@ -1731,12 +1718,6 @@ class DbWriteBase(DbReadBase):
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def set_auto_remove(self):
|
||||
"""
|
||||
BSDDB change log settings using new method with renamed attributes
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def set_default_person_handle(self, handle):
|
||||
"""
|
||||
Set the default Person to the passed instance.
|
||||
|
@ -1064,7 +1064,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
return False
|
||||
return True
|
||||
|
||||
def all_handles(self, table):
|
||||
def _all_handles(self, table):
|
||||
""" return all the keys of a database table
|
||||
|
||||
.. warning:: For speed the keys are directly returned, so on python3
|
||||
@ -1083,7 +1083,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
bytestrings are returned!
|
||||
"""
|
||||
if self.db_is_open:
|
||||
handle_list = self.all_handles(self.person_map)
|
||||
handle_list = self._all_handles(self.person_map)
|
||||
if sort_handles:
|
||||
handle_list.sort(key=self.__sortbyperson_key)
|
||||
return handle_list
|
||||
@ -1101,7 +1101,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
"""
|
||||
|
||||
if self.db_is_open:
|
||||
handle_list = self.all_handles(self.place_map)
|
||||
handle_list = self._all_handles(self.place_map)
|
||||
if sort_handles:
|
||||
handle_list.sort(key=self.__sortbyplace_key)
|
||||
return handle_list
|
||||
@ -1118,7 +1118,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
bytestrings are returned!
|
||||
"""
|
||||
if self.db_is_open:
|
||||
handle_list = self.all_handles(self.source_map)
|
||||
handle_list = self._all_handles(self.source_map)
|
||||
if sort_handles:
|
||||
handle_list.sort(key=self.__sortbysource_key)
|
||||
return handle_list
|
||||
@ -1135,7 +1135,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
bytestrings are returned!
|
||||
"""
|
||||
if self.db_is_open:
|
||||
handle_list = self.all_handles(self.citation_map)
|
||||
handle_list = self._all_handles(self.citation_map)
|
||||
if sort_handles:
|
||||
handle_list.sort(key=self.__sortbycitation_key)
|
||||
return handle_list
|
||||
@ -1152,7 +1152,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
bytestrings are returned!
|
||||
"""
|
||||
if self.db_is_open:
|
||||
handle_list = self.all_handles(self.media_map)
|
||||
handle_list = self._all_handles(self.media_map)
|
||||
if sort_handles:
|
||||
handle_list.sort(key=self.__sortbymedia_key)
|
||||
return handle_list
|
||||
@ -1167,7 +1167,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
bytestrings are returned!
|
||||
"""
|
||||
if self.db_is_open:
|
||||
return self.all_handles(self.event_map)
|
||||
return self._all_handles(self.event_map)
|
||||
return []
|
||||
|
||||
def get_family_handles(self, sort_handles=False):
|
||||
@ -1181,7 +1181,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
bytestrings are returned!
|
||||
"""
|
||||
if self.db_is_open:
|
||||
handle_list = self.all_handles(self.family_map)
|
||||
handle_list = self._all_handles(self.family_map)
|
||||
if sort_handles:
|
||||
handle_list.sort(key=self.__sortbyfamily_key)
|
||||
return handle_list
|
||||
@ -1196,7 +1196,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
bytestrings are returned!
|
||||
"""
|
||||
if self.db_is_open:
|
||||
return self.all_handles(self.repository_map)
|
||||
return self._all_handles(self.repository_map)
|
||||
return []
|
||||
|
||||
def get_note_handles(self):
|
||||
@ -1208,7 +1208,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
bytestrings are returned!
|
||||
"""
|
||||
if self.db_is_open:
|
||||
return self.all_handles(self.note_map)
|
||||
return self._all_handles(self.note_map)
|
||||
return []
|
||||
|
||||
def get_tag_handles(self, sort_handles=False):
|
||||
@ -1222,7 +1222,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
bytestrings are returned!
|
||||
"""
|
||||
if self.db_is_open:
|
||||
handle_list = self.all_handles(self.tag_map)
|
||||
handle_list = self._all_handles(self.tag_map)
|
||||
if sort_handles:
|
||||
handle_list.sort(key=self.__sortbytag_key)
|
||||
return handle_list
|
||||
|
@ -26,7 +26,6 @@ from gramps.gen.proxy import LivingProxyDb
|
||||
|
||||
class DbTest(unittest.TestCase):
|
||||
READ_METHODS = [
|
||||
"all_handles",
|
||||
"close",
|
||||
"db_has_bm_changes",
|
||||
"find_backlink_handles",
|
||||
@ -189,7 +188,6 @@ class DbTest(unittest.TestCase):
|
||||
"add_tag",
|
||||
"add_to_surname_list",
|
||||
"build_surname_list",
|
||||
"commit_base",
|
||||
"commit_event",
|
||||
"commit_family",
|
||||
"commit_media",
|
||||
@ -213,7 +211,6 @@ class DbTest(unittest.TestCase):
|
||||
"remove_repository",
|
||||
"remove_source",
|
||||
"remove_tag",
|
||||
"set_auto_remove",
|
||||
"set_default_person_handle",
|
||||
"set_name_group_mapping",
|
||||
"transaction_begin",
|
||||
|
@ -453,9 +453,6 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
dbmap.open(fname, table_name, dbtype, DBFLAGS_O, DBMODE)
|
||||
return dbmap
|
||||
|
||||
def __all_handles(self, table):
|
||||
return table.keys(self.txn)
|
||||
|
||||
def __log_error(self):
|
||||
mypath = os.path.join(self.get_save_path(),DBRECOVFN)
|
||||
with open(mypath, "w") as ofile:
|
||||
@ -781,7 +778,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
self.env.set_lk_max_objects(DBOBJECTS)
|
||||
|
||||
# Set to auto remove stale logs
|
||||
self.set_auto_remove()
|
||||
self._set_auto_remove()
|
||||
|
||||
# Set not to flush to disk synchronous, this greatly speeds up
|
||||
# database changes, but comes at the cause of loss of durability, so
|
||||
@ -1896,7 +1893,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
if 'cursor' in locals():
|
||||
cursor.close()
|
||||
|
||||
def commit_base(self, obj, data_map, key, transaction, change_time):
|
||||
def _commit_base(self, obj, data_map, key, transaction, change_time):
|
||||
"""
|
||||
Commit the specified object to the database, storing the changes as
|
||||
part of the transaction.
|
||||
@ -1925,7 +1922,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
Commit the specified Person to the database, storing the changes as
|
||||
part of the transaction.
|
||||
"""
|
||||
old_data = self.commit_base(
|
||||
old_data = self._commit_base(
|
||||
person, self.person_map, PERSON_KEY, transaction, change_time)
|
||||
|
||||
if old_data:
|
||||
@ -1984,7 +1981,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
Commit the specified Media to the database, storing the changes
|
||||
as part of the transaction.
|
||||
"""
|
||||
self.commit_base(obj, self.media_map, MEDIA_KEY,
|
||||
self._commit_base(obj, self.media_map, MEDIA_KEY,
|
||||
transaction, change_time)
|
||||
|
||||
self.media_attributes.update(
|
||||
@ -1996,7 +1993,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
Commit the specified Source to the database, storing the changes as
|
||||
part of the transaction.
|
||||
"""
|
||||
self.commit_base(source, self.source_map, SOURCE_KEY,
|
||||
self._commit_base(source, self.source_map, SOURCE_KEY,
|
||||
transaction, change_time)
|
||||
|
||||
self.source_media_types.update(
|
||||
@ -2018,7 +2015,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
Commit the specified Citation to the database, storing the changes as
|
||||
part of the transaction.
|
||||
"""
|
||||
self.commit_base(citation, self.citation_map, CITATION_KEY,
|
||||
self._commit_base(citation, self.citation_map, CITATION_KEY,
|
||||
transaction, change_time)
|
||||
|
||||
attr_list = []
|
||||
@ -2036,7 +2033,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
Commit the specified Place to the database, storing the changes as
|
||||
part of the transaction.
|
||||
"""
|
||||
self.commit_base(place, self.place_map, PLACE_KEY,
|
||||
self._commit_base(place, self.place_map, PLACE_KEY,
|
||||
transaction, change_time)
|
||||
|
||||
if place.get_type().is_custom():
|
||||
@ -2056,7 +2053,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
Commit the specified Event to the database, storing the changes as
|
||||
part of the transaction.
|
||||
"""
|
||||
self.commit_base(event, self.event_map, EVENT_KEY,
|
||||
self._commit_base(event, self.event_map, EVENT_KEY,
|
||||
transaction, change_time)
|
||||
|
||||
self.event_attributes.update(
|
||||
@ -2077,7 +2074,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
Commit the specified Family to the database, storing the changes as
|
||||
part of the transaction.
|
||||
"""
|
||||
self.commit_base(family, self.family_map, FAMILY_KEY,
|
||||
self._commit_base(family, self.family_map, FAMILY_KEY,
|
||||
transaction, change_time)
|
||||
|
||||
self.family_attributes.update(
|
||||
@ -2110,7 +2107,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
Commit the specified Repository to the database, storing the changes
|
||||
as part of the transaction.
|
||||
"""
|
||||
self.commit_base(repository, self.repository_map, REPOSITORY_KEY,
|
||||
self._commit_base(repository, self.repository_map, REPOSITORY_KEY,
|
||||
transaction, change_time)
|
||||
|
||||
if repository.type.is_custom():
|
||||
@ -2124,7 +2121,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
Commit the specified Note to the database, storing the changes as part
|
||||
of the transaction.
|
||||
"""
|
||||
self.commit_base(note, self.note_map, NOTE_KEY,
|
||||
self._commit_base(note, self.note_map, NOTE_KEY,
|
||||
transaction, change_time)
|
||||
|
||||
if note.type.is_custom():
|
||||
@ -2135,7 +2132,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
Commit the specified Tag to the database, storing the changes as part
|
||||
of the transaction.
|
||||
"""
|
||||
self.commit_base(tag, self.tag_map, TAG_KEY,
|
||||
self._commit_base(tag, self.tag_map, TAG_KEY,
|
||||
transaction, change_time)
|
||||
|
||||
def get_from_handle(self, handle, class_type, data_map):
|
||||
@ -2373,7 +2370,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
|
||||
_LOG.debug("Upgrade time: %d seconds" % int(time.time()-t))
|
||||
|
||||
def set_auto_remove(self):
|
||||
def _set_auto_remove(self):
|
||||
"""
|
||||
BSDDB change log settings using new method with renamed attributes
|
||||
"""
|
||||
@ -2404,7 +2401,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
self.env.set_lk_max_objects(DBOBJECTS)
|
||||
|
||||
# clean up unused logs
|
||||
self.set_auto_remove()
|
||||
self._set_auto_remove()
|
||||
|
||||
# The DB_PRIVATE flag must go if we ever move to multi-user setup
|
||||
env_flags = db.DB_CREATE | db.DB_PRIVATE |\
|
||||
|
@ -242,14 +242,6 @@ class DummyDb(M_A_M_B("NewBaseClass", (DbReadBase, Callback, object,), {})):
|
||||
"""
|
||||
self.__feature[feature] = value
|
||||
|
||||
def all_handles(self, table):
|
||||
"""
|
||||
Return all handles from the specified table as a list
|
||||
"""
|
||||
if not self.db_is_open:
|
||||
LOG.warn("database is closed")
|
||||
return []
|
||||
|
||||
def close(self, update=True, user=None):
|
||||
"""
|
||||
Close the specified database.
|
||||
|
Loading…
Reference in New Issue
Block a user