* src/GrampsBSDDB.py (upgrade_*): Use transaction for commits.

svn: r4713
This commit is contained in:
Alex Roitman 2005-05-27 19:14:20 +00:00
parent 5610229889
commit 62b8e334af
2 changed files with 23 additions and 9 deletions

View File

@ -2,6 +2,7 @@
* src/GrampsBSDDB.py (upgrade_7): Add upgrade path for repo changes. * src/GrampsBSDDB.py (upgrade_7): Add upgrade path for repo changes.
* src/const.py.in: Define integer constants for standard events. * src/const.py.in: Define integer constants for standard events.
* gramps.glade: Resolve merge conflicts. * gramps.glade: Resolve merge conflicts.
* src/GrampsBSDDB.py (upgrade_*): Use transaction for commits.
2005-05-27 Richard Taylor <rjt-gramps@thegrindstone.me.uk> 2005-05-27 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/EditRepository.py: polish Repository Ref UI * src/EditRepository.py: polish Repository Ref UI

View File

@ -499,6 +499,8 @@ class GrampsBSDDB(GrampsDbBase):
def upgrade_2(self,child_rel_notrans): def upgrade_2(self,child_rel_notrans):
print "Upgrading to DB version 2" print "Upgrading to DB version 2"
trans = Transaction("",self)
trans.set_batch(True)
cursor = self.get_person_cursor() cursor = self.get_person_cursor()
data = cursor.first() data = cursor.first()
while data: while data:
@ -519,12 +521,15 @@ class GrampsBSDDB(GrampsDbBase):
frel = Person.CHILD_REL_BIRTH frel = Person.CHILD_REL_BIRTH
new_list.append((f,mrel,frel)) new_list.append((f,mrel,frel))
person.parent_family_list = new_list person.parent_family_list = new_list
self.commit_person(person,None) self.commit_person(person,trans)
data = cursor.next() data = cursor.next()
cursor.close() cursor.close()
self.transaction_commit(trans,"Upgrade to DB version 2")
def upgrade_3(self): def upgrade_3(self):
print "Upgrading to DB version 3" print "Upgrading to DB version 3"
trans = Transaction("",self)
trans.set_batch(True)
cursor = self.get_person_cursor() cursor = self.get_person_cursor()
data = cursor.first() data = cursor.first()
while data: while data:
@ -535,12 +540,15 @@ class GrampsBSDDB(GrampsDbBase):
person.primary_name.date = None person.primary_name.date = None
for name in person.alternate_names: for name in person.alternate_names:
name.date = None name.date = None
self.commit_person(person,None) self.commit_person(person,trans)
data = cursor.next() data = cursor.next()
cursor.close() cursor.close()
self.transaction_commit(trans,"Upgrade to DB version 3")
def upgrade_4(self,child_rel_notrans): def upgrade_4(self,child_rel_notrans):
print "Upgrading to DB version 4" print "Upgrading to DB version 4"
trans = Transaction("",self)
trans.set_batch(True)
cursor = self.get_person_cursor() cursor = self.get_person_cursor()
data = cursor.first() data = cursor.first()
while data: while data:
@ -561,12 +569,15 @@ class GrampsBSDDB(GrampsDbBase):
new_list.append((f,mrel,frel)) new_list.append((f,mrel,frel))
if change: if change:
person.parent_family_list = new_list person.parent_family_list = new_list
self.commit_person(person,None) self.commit_person(person,trans)
data = cursor.next() data = cursor.next()
cursor.close() cursor.close()
self.transaction_commit(trans,"Upgrade to DB version 4")
def upgrade_5(self): def upgrade_5(self):
print "Upgrading to DB version 5 -- this may take a while" print "Upgrading to DB version 5 -- this may take a while"
trans = Transaction("",self)
trans.set_batch(True)
# Need to rename: # Need to rename:
# attrlist into attribute_list in MediaRefs # attrlist into attribute_list in MediaRefs
# comments into note in SourceRefs # comments into note in SourceRefs
@ -600,7 +611,7 @@ class GrampsBSDDB(GrampsDbBase):
del src_ref.comments del src_ref.comments
changed = True changed = True
if changed: if changed:
self.commit_media_object(obj,None) self.commit_media_object(obj,trans)
data = cursor.next() data = cursor.next()
cursor.close() cursor.close()
# person # person
@ -659,7 +670,7 @@ class GrampsBSDDB(GrampsDbBase):
del src_ref.comments del src_ref.comments
changed = True changed = True
if changed: if changed:
self.commit_person(person,None) self.commit_person(person,trans)
data = cursor.next() data = cursor.next()
cursor.close() cursor.close()
# family # family
@ -704,7 +715,7 @@ class GrampsBSDDB(GrampsDbBase):
del src_ref.comments del src_ref.comments
changed = True changed = True
if changed: if changed:
self.commit_family(family,None) self.commit_family(family,trans)
data = cursor.next() data = cursor.next()
cursor.close() cursor.close()
# event # event
@ -738,7 +749,7 @@ class GrampsBSDDB(GrampsDbBase):
del src_ref.comments del src_ref.comments
changed = True changed = True
if changed: if changed:
self.commit_event(event,None) self.commit_event(event,trans)
data = cursor.next() data = cursor.next()
cursor.close() cursor.close()
# place # place
@ -771,7 +782,7 @@ class GrampsBSDDB(GrampsDbBase):
del src_ref.comments del src_ref.comments
changed = True changed = True
if changed: if changed:
self.commit_place(place,None) self.commit_place(place,trans)
data = cursor.next() data = cursor.next()
cursor.close() cursor.close()
# source # source
@ -799,9 +810,10 @@ class GrampsBSDDB(GrampsDbBase):
del src_ref.comments del src_ref.comments
changed = True changed = True
if changed: if changed:
self.commit_source(source,None) self.commit_source(source,trans)
data = cursor.next() data = cursor.next()
cursor.close() cursor.close()
self.transaction_commit(trans,"Upgrade to DB version 5")
def upgrade_6(self): def upgrade_6(self):
print "Upgrading to DB version 6" print "Upgrading to DB version 6"
@ -827,3 +839,4 @@ class GrampsBSDDB(GrampsDbBase):
self.commit_source(source,trans) self.commit_source(source,trans)
data = cursor.next() data = cursor.next()
cursor.close() cursor.close()
self.transaction_commit(trans,"Upgrade to DB version 7")