Added metadata table and setting/value
This commit is contained in:
parent
e4898df12d
commit
e85b4be7d6
@ -748,7 +748,12 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
return gid
|
return gid
|
||||||
|
|
||||||
def get_mediapath(self):
|
def get_mediapath(self):
|
||||||
return None
|
cur = self.dbapi.execute("select * from metadata where setting = ?", ["media-path"])
|
||||||
|
row = cur.fetchone()
|
||||||
|
if row:
|
||||||
|
return row["value"]
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
def get_name_group_keys(self):
|
def get_name_group_keys(self):
|
||||||
cur = self.dbapi.execute("select name from name_group order by name;")
|
cur = self.dbapi.execute("select name from name_group order by name;")
|
||||||
@ -1125,12 +1130,27 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
self.dbapi.commit()
|
self.dbapi.commit()
|
||||||
|
|
||||||
def set_default_person_handle(self, handle):
|
def set_default_person_handle(self, handle):
|
||||||
## FIXME
|
cur = self.dbapi.execute("select * from metadata where setting = ?", ["default-person"])
|
||||||
pass
|
row = cur.fetchone()
|
||||||
|
if row:
|
||||||
|
cur = self.dbapi.execute("UPDATE metadata SET value = ? WHERE setting = ?;",
|
||||||
|
[handle, "default-person"])
|
||||||
|
else:
|
||||||
|
cur = self.dbapi.execute("INSERT INTO metadata (setting, value) VALUES (?, ?);",
|
||||||
|
["default-person", handle])
|
||||||
|
self.emit('home-person-changed')
|
||||||
|
self.dbapi.commit()
|
||||||
|
|
||||||
def set_mediapath(self, mediapath):
|
def set_mediapath(self, mediapath):
|
||||||
## FIXME
|
cur = self.dbapi.execute("select * from metadata where setting = ?", ["media-path"])
|
||||||
pass
|
row = cur.fetchone()
|
||||||
|
if row:
|
||||||
|
cur = self.dbapi.execute("UPDATE metadata SET value = ? WHERE setting = ?;",
|
||||||
|
[mediapath, "media-path"])
|
||||||
|
else:
|
||||||
|
cur = self.dbapi.execute("INSERT INTO metadata (setting, value) VALUES (?, ?);",
|
||||||
|
["media-path", mediapath])
|
||||||
|
self.dbapi.commit()
|
||||||
|
|
||||||
def get_raw_person_data(self, handle):
|
def get_raw_person_data(self, handle):
|
||||||
if handle in self.person_map:
|
if handle in self.person_map:
|
||||||
@ -1615,6 +1635,8 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
#del self.person_id_map[person.gramps_id]
|
#del self.person_id_map[person.gramps_id]
|
||||||
self.dbapi.execute("DELETE from person WHERE handle = ?;", [handle])
|
self.dbapi.execute("DELETE from person WHERE handle = ?;", [handle])
|
||||||
self.emit("person-delete", ([handle],))
|
self.emit("person-delete", ([handle],))
|
||||||
|
if not transaction.batch:
|
||||||
|
self.dbapi.commit()
|
||||||
|
|
||||||
def remove_source(self, handle, transaction):
|
def remove_source(self, handle, transaction):
|
||||||
"""
|
"""
|
||||||
@ -1715,6 +1737,8 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
self.dbapi.execute("DELETE from %s WHERE handle = ?;" % key2table[key],
|
self.dbapi.execute("DELETE from %s WHERE handle = ?;" % key2table[key],
|
||||||
[handle])
|
[handle])
|
||||||
self.emit(KEY_TO_NAME_MAP[key] + "-delete", ([handle],))
|
self.emit(KEY_TO_NAME_MAP[key] + "-delete", ([handle],))
|
||||||
|
if not transaction.batch:
|
||||||
|
self.dbapi.commit()
|
||||||
|
|
||||||
## Missing:
|
## Missing:
|
||||||
|
|
||||||
@ -1778,10 +1802,12 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
return self.citation_bookmarks
|
return self.citation_bookmarks
|
||||||
|
|
||||||
def get_default_handle(self):
|
def get_default_handle(self):
|
||||||
items = self.person_map.keys()
|
cur = self.dbapi.execute("select * from metadata where setting = ?", ["default-person"])
|
||||||
if len(items) > 0:
|
row = cur.fetchone()
|
||||||
return list(items)[0]
|
if row:
|
||||||
return None
|
return row["value"]
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
def get_event_attribute_types(self):
|
def get_event_attribute_types(self):
|
||||||
## FIXME
|
## FIXME
|
||||||
@ -2017,6 +2043,10 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
name TEXT PRIMARY KEY NOT NULL,
|
name TEXT PRIMARY KEY NOT NULL,
|
||||||
grouping TEXT
|
grouping TEXT
|
||||||
);""")
|
);""")
|
||||||
|
self.dbapi.execute("""CREATE TABLE IF NOT EXISTS metadata (
|
||||||
|
setting TEXT PRIMARY KEY NOT NULL,
|
||||||
|
value TEXT
|
||||||
|
);""")
|
||||||
## Indices:
|
## Indices:
|
||||||
self.dbapi.execute("""CREATE INDEX IF NOT EXISTS
|
self.dbapi.execute("""CREATE INDEX IF NOT EXISTS
|
||||||
order_by ON person (order_by);
|
order_by ON person (order_by);
|
||||||
|
Loading…
Reference in New Issue
Block a user