Updates for ZODB

svn: r998
This commit is contained in:
Don Allingham 2002-05-18 20:35:24 +00:00
parent 78e1dffde7
commit a5a646e17f
7 changed files with 109 additions and 40 deletions

View File

@ -86,8 +86,9 @@ class EditPerson:
self.pmap = {} self.pmap = {}
self.add_places = [] self.add_places = []
for p in db.getPlaces(): for key in db.getPlaceKeys():
self.pmap[p.get_title()] = p p = db.getPlaceDisplay(key)
self.pmap[p[0]] = key
self.load_obj = None self.load_obj = None
self.top = libglade.GladeXML(const.editPersonFile, "editPerson") self.top = libglade.GladeXML(const.editPersonFile, "editPerson")
@ -777,9 +778,10 @@ class EditPerson:
text = self.notes_field.get_chars(0,-1) text = self.notes_field.get_chars(0,-1)
idval = self.gid.get_text() idval = self.gid.get_text()
self.pmap = {} # self.pmap = {}
for p in self.db.getPlaces(): # for key in db.getPlaceKeys():
self.pmap[p.get_title()] = p # p = db.getPlaceDisplay(key)
# self.pmap[p[0]] = key
changed = 0 changed = 0
name = self.person.getPrimaryName() name = self.person.getPrimaryName()
@ -807,7 +809,7 @@ class EditPerson:
dplace = string.strip(self.dplace.get_text()) dplace = string.strip(self.dplace.get_text())
if self.pmap.has_key(bplace): if self.pmap.has_key(bplace):
p1 = self.pmap[bplace] p1 = self.db.getPlaceMap()[self.pmap[bplace]]
else: else:
p1 = None p1 = None
if bplace != "": if bplace != "":
@ -815,7 +817,7 @@ class EditPerson:
self.birth.setPlace(p1) self.birth.setPlace(p1)
if self.pmap.has_key(dplace): if self.pmap.has_key(dplace):
p1 = self.pmap[dplace] p1 = self.db.getPlaceMap()[self.pmap[dplace]]
else: else:
p1 = None p1 = None
if dplace != "": if dplace != "":
@ -1157,8 +1159,9 @@ class EditPerson:
Utils.modified() Utils.modified()
self.pmap = {} self.pmap = {}
for p in self.db.getPlaces(): for p in self.db.getPlaceKeys():
self.pmap[p.get_title()] = p p = db.getPlaceDisplay(key)
self.pmap[p[0]] = key
self.birth.setDate(self.bdate.get_text()) self.birth.setDate(self.bdate.get_text())
self.birth.setPlace(self.get_place(self.bplace,1)) self.birth.setPlace(self.get_place(self.bplace,1))
@ -1302,12 +1305,12 @@ class EditPerson:
text = string.strip(field.get_text()) text = string.strip(field.get_text())
if text: if text:
if self.pmap.has_key(text): if self.pmap.has_key(text):
return self.pmap[text] return self.db.getPlaceMap()[self.pmap[text]]
elif makenew: elif makenew:
place = Place() place = Place()
place.set_title(text) place.set_title(text)
self.pmap[text] = place
self.db.addPlace(place) self.db.addPlace(place)
self.pmap[text] = place.getId()
self.add_places.append(place) self.add_places.append(place)
Utils.modified() Utils.modified()
return place return place

View File

@ -59,9 +59,9 @@ class EventEditor:
self.callback = cb self.callback = cb
self.plist = [] self.plist = []
self.pmap = {} for key in db.getPlaceKeys():
for p in self.parent.db.getPlaces(): p = db.getPlaceDisplay(key)
self.pmap[p.get_title()] = p self.pmap[p[0]] = key
if event: if event:
self.srcreflist = self.event.getSourceRefList() self.srcreflist = self.event.getSourceRefList()
@ -155,12 +155,12 @@ class EventEditor:
text = strip(field.get_text()) text = strip(field.get_text())
if text != "": if text != "":
if self.pmap.has_key(text): if self.pmap.has_key(text):
return self.pmap[text] return self.db.getPlaceMap()[self.pmap[text]]
elif makenew: elif makenew:
place = Place() place = Place()
place.set_title(text) place.set_title(text)
self.pmap[text] = place
self.parent.db.addPlace(place) self.parent.db.addPlace(place)
self.pmap[text] = place.getId()
self.plist.append(place) self.plist.append(place)
Utils.modified() Utils.modified()
return place return place

View File

@ -153,11 +153,25 @@ class GrampsZODB(GrampsDB):
self.load(name,callback) self.load(name,callback)
def load(self,name,callback): def load(self,name,callback):
import time
t = time.time()
print 'opening storage'
s = FileStorage(name) s = FileStorage(name)
t1 = time.time()
print t1 - t
print 'getting DB'
self.db = DB(s) self.db = DB(s)
t = time.time()
print t - t1
print 'establishing connect'
self.conn = self.db.open() self.conn = self.db.open()
t1 = time.time()
print t1 -t
print 'getting root'
root = self.conn.root() root = self.conn.root()
t = time.time()
print t - t1
print 'family map'
need_commit = 0 need_commit = 0
if root.has_key('fm'): if root.has_key('fm'):
self.familyMap = root['fm'] self.familyMap = root['fm']
@ -165,14 +179,20 @@ class GrampsZODB(GrampsDB):
self.familyMap = OOBTree() self.familyMap = OOBTree()
root['fm'] = self.familyMap root['fm'] = self.familyMap
need_commit = 1 need_commit = 1
t1 = time.time()
print t1 - t
print 'person map'
if root.has_key('pm'): if root.has_key('pm'):
self.personMap = root['pm'] self.personMap = root['pm']
else: else:
self.personMap = PersonMap() self.personMap = PersonMap()
root['pm'] = self.personMap root['pm'] = self.personMap
need_commit = 1 need_commit = 1
t = time.time()
print t - t1
print 'person index table'
if root.has_key('pmt'): if root.has_key('pmt'):
self.personTable = root['pmt'] self.personTable = root['pmt']
else: else:
@ -181,7 +201,10 @@ class GrampsZODB(GrampsDB):
self.personTable[key] = person.getDisplayInfo() self.personTable[key] = person.getDisplayInfo()
root['pmt'] = self.personTable root['pmt'] = self.personTable
need_commit = 1 need_commit = 1
t1 = time.time()
print t1 - t
print 'surnames'
if root.has_key('surnames'): if root.has_key('surnames'):
self.surnames = root['surnames'] self.surnames = root['surnames']
else: else:
@ -190,14 +213,20 @@ class GrampsZODB(GrampsDB):
self.addSurname(person.getPrimaryName().getSurname()) self.addSurname(person.getPrimaryName().getSurname())
root['surnames'] = self.surnames root['surnames'] = self.surnames
need_commit = 1 need_commit = 1
t = time.time()
print t - t1
print 'source map'
if root.has_key('sm'): if root.has_key('sm'):
self.sourceMap = root['sm'] self.sourceMap = root['sm']
else: else:
self.sourceMap = OOBTree() self.sourceMap = OOBTree()
root['sm'] = self.sourceMap root['sm'] = self.sourceMap
need_commit = 1 need_commit = 1
t1 = time.time()
print t1 - t
print 'source index table'
if root.has_key('smt'): if root.has_key('smt'):
self.sourceTable = root['smt'] self.sourceTable = root['smt']
else: else:
@ -206,14 +235,20 @@ class GrampsZODB(GrampsDB):
self.sourceTable[key] = src.getDisplayInfo() self.sourceTable[key] = src.getDisplayInfo()
root['smt'] = self.sourceTable root['smt'] = self.sourceTable
need_commit = 1 need_commit = 1
t = time.time()
print t - t1
print 'place map'
if root.has_key('plm'): if root.has_key('plm'):
self.placeMap = root['plm'] self.placeMap = root['plm']
else: else:
self.placeMap = OOBTree() self.placeMap = OOBTree()
root['plm'] = self.placeMap root['plm'] = self.placeMap
need_commit = 1 need_commit = 1
t1 = time.time()
print t1 - t
print 'place index'
if root.has_key('plmt'): if root.has_key('plmt'):
self.placeTable = root['plmt'] self.placeTable = root['plmt']
else: else:
@ -222,23 +257,35 @@ class GrampsZODB(GrampsDB):
self.placeTable[key] = place.getDisplayInfo() self.placeTable[key] = place.getDisplayInfo()
root['plmt'] = self.placeTable root['plmt'] = self.placeTable
need_commit = 1 need_commit = 1
t = time.time()
print t - t1
print 'default person'
if root.has_key('default'): if root.has_key('default'):
self.default = root['default'] self.default = root['default']
else: else:
self.default = None self.default = None
root['default'] = self.default root['default'] = self.default
need_commit = 1 need_commit = 1
t1 = time.time()
print t1 - t
print 'bookmarks'
if root.has_key('bookmarks'): if root.has_key('bookmarks'):
self.bookmarks = root['bookmarks'] self.bookmarks = root['bookmarks']
else: else:
self.bookmarks = [] self.bookmarks = []
root['bookmarks'] = self.bookmarks root['bookmarks'] = self.bookmarks
need_commit = 1 need_commit = 1
t = time.time()
print t - t1
if need_commit: if need_commit:
print 'committing'
get_transaction().commit() get_transaction().commit()
t1 = time.time()
print t1 - t
print 'done'
return 1 return 1
def setDefaultPerson(self,person): def setDefaultPerson(self,person):

View File

@ -68,8 +68,10 @@ class Marriage:
self.path = db.getSavePath() self.path = db.getSavePath()
self.cb = callback self.cb = callback
self.pmap = {} self.pmap = {}
for p in db.getPlaces():
self.pmap[p.get_title()] = p for key in db.getPlaceKeys():
p = db.getPlaceDisplay(key)
self.pmap[p[0]] = key
self.top = libglade.GladeXML(const.marriageFile,"marriageEditor") self.top = libglade.GladeXML(const.marriageFile,"marriageEditor")
top_window = self.get_widget("marriageEditor") top_window = self.get_widget("marriageEditor")

View File

@ -112,15 +112,15 @@ class PlaceView:
index = 0 index = 0
for key in self.db.getPlaceKeys(): for key in self.db.getPlaceKeys():
src = self.db.getPlaceMap()[key] self.place_list.append(self.db.getPlaceDisplay(key))
self.place_list.append(src.getDisplayInfo()) self.place_list.set_row_data(index,key)
self.place_list.set_row_data(index,src)
index = index + 1 index = index + 1
if index > 0: if index > 0:
self.place_list.select_row(current_row,0) self.place_list.select_row(current_row,0)
self.place_list.moveto(current_row) self.place_list.moveto(current_row)
self.active = self.place_list.get_row_data(current_row) id = self.place_list.get_row_data(current_row)
self.active = self.db.getPlaceMap()[id]
else: else:
self.active = None self.active = None
@ -129,7 +129,8 @@ class PlaceView:
def select_row(self,obj,row,b,c): def select_row(self,obj,row,b,c):
if row == obj.selection[0]: if row == obj.selection[0]:
self.active = self.place_list.get_row_data(row) id = self.place_list.get_row_data(row)
self.active = self.db.getPlaceMap()[id]
def merge(self): def merge(self):
if len(self.place_list.selection) != 2: if len(self.place_list.selection) != 2:
@ -139,6 +140,8 @@ class PlaceView:
import MergeData import MergeData
p1 = self.place_list.get_row_data(self.place_list.selection[0]) p1 = self.place_list.get_row_data(self.place_list.selection[0])
p2 = self.place_list.get_row_data(self.place_list.selection[1]) p2 = self.place_list.get_row_data(self.place_list.selection[1])
p1 = self.db.getPlaceMap()[p1]
p2 = self.db.getPlaceMap()[p2]
MergeData.MergePlaces(self.db,p1,p2,self.load_places) MergeData.MergePlaces(self.db,p1,p2,self.load_places)
def on_button_press_event(self,obj,event): def on_button_press_event(self,obj,event):
@ -161,7 +164,8 @@ class PlaceView:
def on_click_column(self,obj,column): def on_click_column(self,obj,column):
obj.freeze() obj.freeze()
if len(obj.selection): if len(obj.selection):
sel = obj.get_row_data(obj.selection[0]) id = obj.get_row_data(obj.selection[0])
sel = self.db.getPlaceMap()[id]
else: else:
sel = None sel = None
@ -223,8 +227,9 @@ class PlaceView:
index = obj.selection[0] index = obj.selection[0]
used = 0 used = 0
place = obj.get_row_data(index) place = self.db.getPlaceMap()[obj.get_row_data(index)]
for p in self.db.getPersonMap().values(): for key in self.db.getPersonKeys():
p = self.db.getPersonMap()[key]
for event in [p.getBirth(), p.getDeath()] + p.getEventList(): for event in [p.getBirth(), p.getDeath()] + p.getEventList():
if event.getPlace() == place: if event.getPlace() == place:
used = 1 used = 1
@ -241,8 +246,7 @@ class PlaceView:
_('Keep Place')) _('Keep Place'))
else: else:
obj.remove(index) obj.remove(index)
map = self.db.getPlaceMap() self.db.removePlace(place.getId())
del map[place.getId()]
Utils.modified() Utils.modified()
def on_edit_place_clicked(self,obj): def on_edit_place_clicked(self,obj):

View File

@ -107,7 +107,8 @@ class SourceView:
data = None data = None
if len(obj.selection) == 1: if len(obj.selection) == 1:
data = obj.get_row_data(obj.selection[0]) id = obj.get_row_data(obj.selection[0])
data = self.db.getSourceMap()[data]
obj.freeze() obj.freeze()
if new_col == self.scol: if new_col == self.scol:
@ -143,9 +144,8 @@ class SourceView:
index = 0 index = 0
for key in self.db.getSourceKeys(): for key in self.db.getSourceKeys():
src = self.db.getSourceMap()[key] self.source_list.append(self.db.getSourceDisplay(key))
self.source_list.append(src.getDisplayInfo()) self.source_list.set_row_data(index,key)
self.source_list.set_row_data(index,src)
index = index + 1 index = index + 1
if index > 0: if index > 0:
@ -159,7 +159,7 @@ class SourceView:
if event.button == 1 and event.type == GDK._2BUTTON_PRESS: if event.button == 1 and event.type == GDK._2BUTTON_PRESS:
if len(obj.selection) > 0: if len(obj.selection) > 0:
index = obj.selection[0] index = obj.selection[0]
source = obj.get_row_data(index) source = self.db.getSourceMap()[obj.get_row_data(index)]
EditSource.EditSource(source,self.db, EditSource.EditSource(source,self.db,
self.update_display_after_edit) self.update_display_after_edit)
@ -172,7 +172,7 @@ class SourceView:
else: else:
index = obj.selection[0] index = obj.selection[0]
source = obj.get_row_data(index) source = self.db.getSourceMap()[obj.get_row_data(index)]
if self.is_source_used(source): if self.is_source_used(source):
ans = EditSource.DelSrcQuery(source,self.db,self.update) ans = EditSource.DelSrcQuery(source,self.db,self.update)
@ -182,8 +182,7 @@ class SourceView:
_('Delete Source'),ans.query_response, _('Delete Source'),ans.query_response,
_('Keep Source')) _('Keep Source'))
else: else:
map = self.db.getSourceMap() self.db.removeSource(source.getId())
del map[source.getId()]
Utils.modified() Utils.modified()
self.update(0) self.update(0)
@ -227,7 +226,7 @@ class SourceView:
def on_edit_source_clicked(self,obj): def on_edit_source_clicked(self,obj):
if len(obj.selection) > 0: if len(obj.selection) > 0:
index = obj.selection[0] index = obj.selection[0]
source = obj.get_row_data(index) source = self.db.getSourceMap()[obj.get_row_data(index)]
EditSource.EditSource(source,self.db, EditSource.EditSource(source,self.db,
self.update_display_after_edit) self.update_display_after_edit)

View File

@ -659,12 +659,26 @@ class Gramps:
self.child_list.set_column_visibility(self.c_details,GrampsCfg.show_detail) self.child_list.set_column_visibility(self.c_details,GrampsCfg.show_detail)
self.child_list.set_column_visibility(self.c_id,GrampsCfg.id_visible) self.child_list.set_column_visibility(self.c_id,GrampsCfg.id_visible)
self.child_list.set_column_visibility(self.c_birth_order,GrampsCfg.index_visible) self.child_list.set_column_visibility(self.c_birth_order,GrampsCfg.index_visible)
import time
t = time.time()
self.apply_filter() self.apply_filter()
print 'people',time.time() - t
t = time.time()
self.load_family() self.load_family()
print 'family',time.time() -t
t = time.time()
self.source_view.load_sources() self.source_view.load_sources()
print 'sources',time.time() -t
t = time.time()
self.place_view.load_places() self.place_view.load_places()
print 'places',time.time() -t
t = time.time()
self.pedigree_view.load_canvas(self.active_person) self.pedigree_view.load_canvas(self.active_person)
print 'pedegree',time.time() -t
t = time.time()
self.media_view.load_media() self.media_view.load_media()
print 'media',time.time() -t
t = time.time()
self.toolbar.set_style(GrampsCfg.toolbar) self.toolbar.set_style(GrampsCfg.toolbar)
def update_display(self,changed): def update_display(self,changed):