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