Merge updates for ZODB, surnames saved as a PersistentList so that ZODB sees the changes
svn: r1012
This commit is contained in:
parent
88ac40491c
commit
718fd9a3fe
@ -19,6 +19,7 @@
|
||||
#
|
||||
|
||||
from ZODB import Persistent
|
||||
from ZODB.PersistentList import PersistentList
|
||||
from ZODB.dbmStorage import gdbmStorage
|
||||
from ZODB.DB import DB
|
||||
from BTrees.OOBTree import OOBTree
|
||||
@ -198,6 +199,7 @@ class GrampsZODB(GrampsDB):
|
||||
if self.root.has_key('surnames'):
|
||||
self.surnames = self.root['surnames']
|
||||
else:
|
||||
self.surnames = PersistentList()
|
||||
for key in self.personMap.keys():
|
||||
person = self.personMap[key]
|
||||
self.addSurname(person.getPrimaryName().getSurname())
|
||||
|
@ -249,6 +249,7 @@ class MergePeople:
|
||||
self.p1.addUrl(xdata)
|
||||
|
||||
self.id2 = self.glade.get_widget("id2")
|
||||
old_id = self.p1.getId()
|
||||
if self.id2.get_active():
|
||||
self.p1.setId(self.p2.getId())
|
||||
|
||||
@ -320,10 +321,11 @@ class MergePeople:
|
||||
self.p1.setNote(old_note + self.p2.getNote())
|
||||
|
||||
try:
|
||||
del self.db.getPersonMap()[self.p2.getId()]
|
||||
self.db.removePerson(self.p2.getId())
|
||||
self.db.buildPersonDisplay(self.p1.getId(),old_id)
|
||||
except:
|
||||
print "%s is not in the person map!" % (GrampsCfg.nameof(self.p2))
|
||||
self.update(self.p1,self.p2)
|
||||
self.update(self.p1,self.p2,old_id)
|
||||
Utils.destroy_passed_object(self.top)
|
||||
|
||||
def find_family(self,family):
|
||||
@ -335,8 +337,7 @@ class MergePeople:
|
||||
mother = self.p1
|
||||
|
||||
for myfamily in self.family_list:
|
||||
if myfamily.getFather() == father and \
|
||||
myfamily.getMother() == mother:
|
||||
if myfamily.getFather() == father and myfamily.getMother() == mother:
|
||||
return myfamily
|
||||
return None
|
||||
|
||||
@ -804,6 +805,7 @@ class MergePlaces:
|
||||
def on_merge_places_clicked(self,obj):
|
||||
t2active = self.glade.get_widget("title2").get_active()
|
||||
|
||||
old_id = self.p1.getId()
|
||||
if t2active:
|
||||
self.p1.set_title(self.p2.get_title())
|
||||
elif self.glade.get_widget("title3").get_active():
|
||||
@ -846,7 +848,9 @@ class MergePlaces:
|
||||
for event in f.getEventList():
|
||||
if event.getPlace() == self.p2:
|
||||
event.setPlace(self.p1)
|
||||
del self.db.getPlaceMap()[self.p2.getId()]
|
||||
self.db.removePlace(self.p2.getId())
|
||||
self.db.buildPlaceDisplay(self.p1.getId(),old_id)
|
||||
|
||||
self.update()
|
||||
Utils.modified()
|
||||
Utils.destroy_passed_object(obj)
|
||||
|
@ -1849,8 +1849,10 @@ class GrampsDB(Persistent):
|
||||
def buildPersonDisplay(self,nkey,okey=None):
|
||||
if nkey != okey and okey != None:
|
||||
del self.personTable[okey]
|
||||
self.personTable[nkey] = self.personMap[nkey].getDisplayInfo()
|
||||
|
||||
person = self.personMap[nkey]
|
||||
self.personTable[nkey] = person.getDisplayInfo()
|
||||
self.addSurname(person.getPrimaryName().getSurname())
|
||||
|
||||
def buildPlaceDisplay(self,nkey,okey=None):
|
||||
if nkey != okey and okey != None:
|
||||
del self.placeTable[okey]
|
||||
|
@ -403,8 +403,7 @@ class Gramps:
|
||||
p2 = self.person_list.get_row_data(self.person_list.selection[1])
|
||||
p1 = self.db.getPerson(p1)
|
||||
p2 = self.db.getPerson(p2)
|
||||
MergeData.MergePeople(self.db,p1,p2,self.merge_update,
|
||||
self.update_after_edit)
|
||||
MergeData.MergePeople(self.db,p1,p2,self.merge_update,self.update_after_edit)
|
||||
elif page == 4:
|
||||
self.place_view.merge()
|
||||
|
||||
@ -947,8 +946,8 @@ class Gramps:
|
||||
self.active_person = self.db.getPerson(p)
|
||||
self.person_list.thaw()
|
||||
|
||||
def merge_update(self,p1,p2):
|
||||
self.remove_from_person_list(p1)
|
||||
def merge_update(self,p1,p2,old_id):
|
||||
self.remove_from_person_list(p1,old_id)
|
||||
self.remove_from_person_list(p2)
|
||||
self.redisplay_person_list(p1)
|
||||
|
||||
@ -1431,6 +1430,13 @@ class Gramps:
|
||||
self.place_view.new_place_after_edit(p)
|
||||
self.update_display(0)
|
||||
|
||||
def update_after_merge(self,person,old_id):
|
||||
if epo:
|
||||
print person,old_id
|
||||
self.remove_from_person_list(person,old_id)
|
||||
self.redisplay_person_list(person)
|
||||
self.update_display(0)
|
||||
|
||||
def redisplay_person_list(self,person):
|
||||
self.id2col[person.getId()] = 1
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user