Now using batch transactions
This commit is contained in:
parent
d69f8a6d3c
commit
8be61709b8
@ -495,16 +495,14 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def transaction_commit(self, txn):
|
def transaction_commit(self, txn):
|
||||||
## FIXME
|
self.dbapi.commit()
|
||||||
pass
|
|
||||||
|
|
||||||
def get_undodb(self):
|
def get_undodb(self):
|
||||||
## FIXME
|
## FIXME
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def transaction_abort(self, txn):
|
def transaction_abort(self, txn):
|
||||||
## FIXME
|
self.dbapi.rollback()
|
||||||
pass
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _validated_id_prefix(val, default):
|
def _validated_id_prefix(val, default):
|
||||||
@ -1248,7 +1246,6 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
|
|
||||||
def commit_person(self, person, trans, change_time=None):
|
def commit_person(self, person, trans, change_time=None):
|
||||||
emit = None
|
emit = None
|
||||||
if True or not trans.batch:
|
|
||||||
if person.handle in self.person_map:
|
if person.handle in self.person_map:
|
||||||
emit = "person-update"
|
emit = "person-update"
|
||||||
self.dbapi.execute("""UPDATE person SET gramps_id = ?,
|
self.dbapi.execute("""UPDATE person SET gramps_id = ?,
|
||||||
@ -1267,6 +1264,7 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
self._order_by_person_key(person),
|
self._order_by_person_key(person),
|
||||||
person.gramps_id,
|
person.gramps_id,
|
||||||
pickle.dumps(person.serialize())])
|
pickle.dumps(person.serialize())])
|
||||||
|
if not trans.batch:
|
||||||
self.dbapi.commit()
|
self.dbapi.commit()
|
||||||
# Emit after added:
|
# Emit after added:
|
||||||
if emit:
|
if emit:
|
||||||
@ -1274,7 +1272,6 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
|
|
||||||
def commit_family(self, family, trans, change_time=None):
|
def commit_family(self, family, trans, change_time=None):
|
||||||
emit = None
|
emit = None
|
||||||
if True or not trans.batch:
|
|
||||||
if family.handle in self.family_map:
|
if family.handle in self.family_map:
|
||||||
emit = "family-update"
|
emit = "family-update"
|
||||||
self.dbapi.execute("""UPDATE family SET gramps_id = ?,
|
self.dbapi.execute("""UPDATE family SET gramps_id = ?,
|
||||||
@ -1288,6 +1285,7 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
self.dbapi.execute("insert into family values(?, ?, ?);",
|
self.dbapi.execute("insert into family values(?, ?, ?);",
|
||||||
[family.handle, family.gramps_id,
|
[family.handle, family.gramps_id,
|
||||||
pickle.dumps(family.serialize())])
|
pickle.dumps(family.serialize())])
|
||||||
|
if not trans.batch:
|
||||||
self.dbapi.commit()
|
self.dbapi.commit()
|
||||||
# Emit after added:
|
# Emit after added:
|
||||||
if emit:
|
if emit:
|
||||||
@ -1295,7 +1293,6 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
|
|
||||||
def commit_citation(self, citation, trans, change_time=None):
|
def commit_citation(self, citation, trans, change_time=None):
|
||||||
emit = None
|
emit = None
|
||||||
if True or not trans.batch:
|
|
||||||
if citation.handle in self.citation_map:
|
if citation.handle in self.citation_map:
|
||||||
emit = "citation-update"
|
emit = "citation-update"
|
||||||
self.dbapi.execute("""UPDATE citation SET gramps_id = ?,
|
self.dbapi.execute("""UPDATE citation SET gramps_id = ?,
|
||||||
@ -1313,6 +1310,7 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
self._order_by_citation_key(citation),
|
self._order_by_citation_key(citation),
|
||||||
citation.gramps_id,
|
citation.gramps_id,
|
||||||
pickle.dumps(citation.serialize())])
|
pickle.dumps(citation.serialize())])
|
||||||
|
if not trans.batch:
|
||||||
self.dbapi.commit()
|
self.dbapi.commit()
|
||||||
# Emit after added:
|
# Emit after added:
|
||||||
if emit:
|
if emit:
|
||||||
@ -1320,7 +1318,6 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
|
|
||||||
def commit_source(self, source, trans, change_time=None):
|
def commit_source(self, source, trans, change_time=None):
|
||||||
emit = None
|
emit = None
|
||||||
if True or not trans.batch:
|
|
||||||
if source.handle in self.source_map:
|
if source.handle in self.source_map:
|
||||||
emit = "source-update"
|
emit = "source-update"
|
||||||
self.dbapi.execute("""UPDATE source SET gramps_id = ?,
|
self.dbapi.execute("""UPDATE source SET gramps_id = ?,
|
||||||
@ -1338,6 +1335,7 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
self._order_by_source_key(source),
|
self._order_by_source_key(source),
|
||||||
source.gramps_id,
|
source.gramps_id,
|
||||||
pickle.dumps(source.serialize())])
|
pickle.dumps(source.serialize())])
|
||||||
|
if not trans.batch:
|
||||||
self.dbapi.commit()
|
self.dbapi.commit()
|
||||||
# Emit after added:
|
# Emit after added:
|
||||||
if emit:
|
if emit:
|
||||||
@ -1345,7 +1343,6 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
|
|
||||||
def commit_repository(self, repository, trans, change_time=None):
|
def commit_repository(self, repository, trans, change_time=None):
|
||||||
emit = None
|
emit = None
|
||||||
if True or not trans.batch:
|
|
||||||
if repository.handle in self.repository_map:
|
if repository.handle in self.repository_map:
|
||||||
emit = "repository-update"
|
emit = "repository-update"
|
||||||
self.dbapi.execute("""UPDATE repository SET gramps_id = ?,
|
self.dbapi.execute("""UPDATE repository SET gramps_id = ?,
|
||||||
@ -1358,6 +1355,7 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
emit = "repository-add"
|
emit = "repository-add"
|
||||||
self.dbapi.execute("insert into repository values(?, ?, ?);",
|
self.dbapi.execute("insert into repository values(?, ?, ?);",
|
||||||
[repository.handle, repository.gramps_id, pickle.dumps(repository.serialize())])
|
[repository.handle, repository.gramps_id, pickle.dumps(repository.serialize())])
|
||||||
|
if not trans.batch:
|
||||||
self.dbapi.commit()
|
self.dbapi.commit()
|
||||||
# Emit after added:
|
# Emit after added:
|
||||||
if emit:
|
if emit:
|
||||||
@ -1365,7 +1363,6 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
|
|
||||||
def commit_note(self, note, trans, change_time=None):
|
def commit_note(self, note, trans, change_time=None):
|
||||||
emit = None
|
emit = None
|
||||||
if True or not trans.batch:
|
|
||||||
if note.handle in self.note_map:
|
if note.handle in self.note_map:
|
||||||
emit = "note-update"
|
emit = "note-update"
|
||||||
self.dbapi.execute("""UPDATE note SET gramps_id = ?,
|
self.dbapi.execute("""UPDATE note SET gramps_id = ?,
|
||||||
@ -1378,6 +1375,7 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
emit = "note-add"
|
emit = "note-add"
|
||||||
self.dbapi.execute("insert into note values(?, ?, ?);",
|
self.dbapi.execute("insert into note values(?, ?, ?);",
|
||||||
[note.handle, note.gramps_id, pickle.dumps(note.serialize())])
|
[note.handle, note.gramps_id, pickle.dumps(note.serialize())])
|
||||||
|
if not trans.batch:
|
||||||
self.dbapi.commit()
|
self.dbapi.commit()
|
||||||
# Emit after added:
|
# Emit after added:
|
||||||
if emit:
|
if emit:
|
||||||
@ -1385,7 +1383,6 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
|
|
||||||
def commit_place(self, place, trans, change_time=None):
|
def commit_place(self, place, trans, change_time=None):
|
||||||
emit = None
|
emit = None
|
||||||
if True or not trans.batch:
|
|
||||||
if place.handle in self.place_map:
|
if place.handle in self.place_map:
|
||||||
emit = "place-update"
|
emit = "place-update"
|
||||||
self.dbapi.execute("""UPDATE place SET gramps_id = ?,
|
self.dbapi.execute("""UPDATE place SET gramps_id = ?,
|
||||||
@ -1403,6 +1400,7 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
self._order_by_place_key(place),
|
self._order_by_place_key(place),
|
||||||
place.gramps_id,
|
place.gramps_id,
|
||||||
pickle.dumps(place.serialize())])
|
pickle.dumps(place.serialize())])
|
||||||
|
if not trans.batch:
|
||||||
self.dbapi.commit()
|
self.dbapi.commit()
|
||||||
# Emit after added:
|
# Emit after added:
|
||||||
if emit:
|
if emit:
|
||||||
@ -1410,7 +1408,6 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
|
|
||||||
def commit_event(self, event, trans, change_time=None):
|
def commit_event(self, event, trans, change_time=None):
|
||||||
emit = None
|
emit = None
|
||||||
if True or not trans.batch:
|
|
||||||
if event.handle in self.event_map:
|
if event.handle in self.event_map:
|
||||||
emit = "event-update"
|
emit = "event-update"
|
||||||
self.dbapi.execute("""UPDATE event SET gramps_id = ?,
|
self.dbapi.execute("""UPDATE event SET gramps_id = ?,
|
||||||
@ -1425,6 +1422,7 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
[event.handle,
|
[event.handle,
|
||||||
event.gramps_id,
|
event.gramps_id,
|
||||||
pickle.dumps(event.serialize())])
|
pickle.dumps(event.serialize())])
|
||||||
|
if not trans.batch:
|
||||||
self.dbapi.commit()
|
self.dbapi.commit()
|
||||||
# Emit after added:
|
# Emit after added:
|
||||||
if emit:
|
if emit:
|
||||||
@ -1432,7 +1430,6 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
|
|
||||||
def commit_tag(self, tag, trans, change_time=None):
|
def commit_tag(self, tag, trans, change_time=None):
|
||||||
emit = None
|
emit = None
|
||||||
if True or not trans.batch:
|
|
||||||
if tag.handle in self.tag_map:
|
if tag.handle in self.tag_map:
|
||||||
emit = "tag-update"
|
emit = "tag-update"
|
||||||
self.dbapi.execute("""UPDATE tag SET blob = ?,
|
self.dbapi.execute("""UPDATE tag SET blob = ?,
|
||||||
@ -1447,6 +1444,7 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
[tag.handle,
|
[tag.handle,
|
||||||
self._order_by_tag_key(tag),
|
self._order_by_tag_key(tag),
|
||||||
pickle.dumps(tag.serialize())])
|
pickle.dumps(tag.serialize())])
|
||||||
|
if not trans.batch:
|
||||||
self.dbapi.commit()
|
self.dbapi.commit()
|
||||||
# Emit after added:
|
# Emit after added:
|
||||||
if emit:
|
if emit:
|
||||||
@ -1454,7 +1452,6 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
|
|
||||||
def commit_media_object(self, media, trans, change_time=None):
|
def commit_media_object(self, media, trans, change_time=None):
|
||||||
emit = None
|
emit = None
|
||||||
if True or not trans.batch:
|
|
||||||
if media.handle in self.media_map:
|
if media.handle in self.media_map:
|
||||||
emit = "media-update"
|
emit = "media-update"
|
||||||
self.dbapi.execute("""UPDATE media SET gramps_id = ?,
|
self.dbapi.execute("""UPDATE media SET gramps_id = ?,
|
||||||
@ -1472,6 +1469,7 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
self._order_by_media_key(media),
|
self._order_by_media_key(media),
|
||||||
media.gramps_id,
|
media.gramps_id,
|
||||||
pickle.dumps(media.serialize())])
|
pickle.dumps(media.serialize())])
|
||||||
|
if not trans.batch:
|
||||||
self.dbapi.commit()
|
self.dbapi.commit()
|
||||||
# Emit after added:
|
# Emit after added:
|
||||||
if emit:
|
if emit:
|
||||||
|
Loading…
Reference in New Issue
Block a user