9744: Tidy up get_raw_*_data methods
This commit is contained in:
parent
3149420f80
commit
6092065fe3
@ -1656,94 +1656,56 @@ class DBAPI(DbGeneric):
|
|||||||
def get_note_gramps_ids(self):
|
def get_note_gramps_ids(self):
|
||||||
return self.get_gramps_ids(NOTE_KEY)
|
return self.get_gramps_ids(NOTE_KEY)
|
||||||
|
|
||||||
def get_raw_person_data(self, key):
|
def get_raw_data(self, obj_key, handle):
|
||||||
if isinstance(key, bytes):
|
key2table = {
|
||||||
key = str(key, "utf-8")
|
PERSON_KEY: 'person',
|
||||||
self.dbapi.execute(
|
FAMILY_KEY: 'family',
|
||||||
"SELECT blob_data FROM person WHERE handle = ?", [key])
|
SOURCE_KEY: 'source',
|
||||||
|
CITATION_KEY: 'citation',
|
||||||
|
EVENT_KEY: 'event',
|
||||||
|
MEDIA_KEY: 'media',
|
||||||
|
PLACE_KEY: 'place',
|
||||||
|
REPOSITORY_KEY: 'repository',
|
||||||
|
NOTE_KEY: 'note',
|
||||||
|
TAG_KEY: 'tag'
|
||||||
|
}
|
||||||
|
if isinstance(handle, bytes):
|
||||||
|
handle = str(handle, "utf-8")
|
||||||
|
sql = "SELECT blob_data FROM %s WHERE handle = ?" % key2table[obj_key]
|
||||||
|
self.dbapi.execute(sql, [handle])
|
||||||
row = self.dbapi.fetchone()
|
row = self.dbapi.fetchone()
|
||||||
if row:
|
if row:
|
||||||
return pickle.loads(row[0])
|
return pickle.loads(row[0])
|
||||||
|
|
||||||
def get_raw_family_data(self, key):
|
def get_raw_person_data(self, handle):
|
||||||
if isinstance(key, bytes):
|
return self.get_raw_data(PERSON_KEY, handle)
|
||||||
key = str(key, "utf-8")
|
|
||||||
self.dbapi.execute(
|
|
||||||
"SELECT blob_data FROM family WHERE handle = ?", [key])
|
|
||||||
row = self.dbapi.fetchone()
|
|
||||||
if row:
|
|
||||||
return pickle.loads(row[0])
|
|
||||||
|
|
||||||
def get_raw_source_data(self, key):
|
def get_raw_family_data(self, handle):
|
||||||
if isinstance(key, bytes):
|
return self.get_raw_data(FAMILY_KEY, handle)
|
||||||
key = str(key, "utf-8")
|
|
||||||
self.dbapi.execute(
|
|
||||||
"SELECT blob_data FROM source WHERE handle = ?", [key])
|
|
||||||
row = self.dbapi.fetchone()
|
|
||||||
if row:
|
|
||||||
return pickle.loads(row[0])
|
|
||||||
|
|
||||||
def get_raw_citation_data(self, key):
|
def get_raw_source_data(self, handle):
|
||||||
if isinstance(key, bytes):
|
return self.get_raw_data(SOURCE_KEY, handle)
|
||||||
key = str(key, "utf-8")
|
|
||||||
self.dbapi.execute(
|
|
||||||
"SELECT blob_data FROM citation WHERE handle = ?", [key])
|
|
||||||
row = self.dbapi.fetchone()
|
|
||||||
if row:
|
|
||||||
return pickle.loads(row[0])
|
|
||||||
|
|
||||||
def get_raw_event_data(self, key):
|
def get_raw_citation_data(self, handle):
|
||||||
if isinstance(key, bytes):
|
return self.get_raw_data(CITATION_KEY, handle)
|
||||||
key = str(key, "utf-8")
|
|
||||||
self.dbapi.execute(
|
|
||||||
"SELECT blob_data FROM event WHERE handle = ?", [key])
|
|
||||||
row = self.dbapi.fetchone()
|
|
||||||
if row:
|
|
||||||
return pickle.loads(row[0])
|
|
||||||
|
|
||||||
def get_raw_media_data(self, key):
|
def get_raw_event_data(self, handle):
|
||||||
if isinstance(key, bytes):
|
return self.get_raw_data(EVENT_KEY, handle)
|
||||||
key = str(key, "utf-8")
|
|
||||||
self.dbapi.execute(
|
|
||||||
"SELECT blob_data FROM media WHERE handle = ?", [key])
|
|
||||||
row = self.dbapi.fetchone()
|
|
||||||
if row:
|
|
||||||
return pickle.loads(row[0])
|
|
||||||
|
|
||||||
def get_raw_place_data(self, key):
|
def get_raw_media_data(self, handle):
|
||||||
if isinstance(key, bytes):
|
return self.get_raw_data(MEDIA_KEY, handle)
|
||||||
key = str(key, "utf-8")
|
|
||||||
self.dbapi.execute(
|
|
||||||
"SELECT blob_data FROM place WHERE handle = ?", [key])
|
|
||||||
row = self.dbapi.fetchone()
|
|
||||||
if row:
|
|
||||||
return pickle.loads(row[0])
|
|
||||||
|
|
||||||
def get_raw_repository_data(self, key):
|
def get_raw_place_data(self, handle):
|
||||||
if isinstance(key, bytes):
|
return self.get_raw_data(PLACE_KEY, handle)
|
||||||
key = str(key, "utf-8")
|
|
||||||
self.dbapi.execute(
|
|
||||||
"SELECT blob_data FROM repository WHERE handle = ?", [key])
|
|
||||||
row = self.dbapi.fetchone()
|
|
||||||
if row:
|
|
||||||
return pickle.loads(row[0])
|
|
||||||
|
|
||||||
def get_raw_note_data(self, key):
|
def get_raw_repository_data(self, handle):
|
||||||
if isinstance(key, bytes):
|
return self.get_raw_data(REPOSITORY_KEY, handle)
|
||||||
key = str(key, "utf-8")
|
|
||||||
self.dbapi.execute(
|
|
||||||
"SELECT blob_data FROM note WHERE handle = ?", [key])
|
|
||||||
row = self.dbapi.fetchone()
|
|
||||||
if row:
|
|
||||||
return pickle.loads(row[0])
|
|
||||||
|
|
||||||
def get_raw_tag_data(self, key):
|
def get_raw_note_data(self, handle):
|
||||||
if isinstance(key, bytes):
|
return self.get_raw_data(NOTE_KEY, handle)
|
||||||
key = str(key, "utf-8")
|
|
||||||
self.dbapi.execute("SELECT blob_data FROM tag WHERE handle = ?", [key])
|
def get_raw_tag_data(self, handle):
|
||||||
row = self.dbapi.fetchone()
|
return self.get_raw_data(TAG_KEY, handle)
|
||||||
if row:
|
|
||||||
return pickle.loads(row[0])
|
|
||||||
|
|
||||||
def _get_raw_person_from_id_data(self, key):
|
def _get_raw_person_from_id_data(self, key):
|
||||||
self.dbapi.execute(
|
self.dbapi.execute(
|
||||||
|
Loading…
Reference in New Issue
Block a user