Updates for ZODB

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

View File

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

View File

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

View File

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

View File

@ -68,8 +68,10 @@ class Marriage:
self.path = db.getSavePath()
self.cb = callback
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")
top_window = self.get_widget("marriageEditor")

View File

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

View File

@ -107,7 +107,8 @@ class SourceView:
data = None
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()
if new_col == self.scol:
@ -143,9 +144,8 @@ class SourceView:
index = 0
for key in self.db.getSourceKeys():
src = self.db.getSourceMap()[key]
self.source_list.append(src.getDisplayInfo())
self.source_list.set_row_data(index,src)
self.source_list.append(self.db.getSourceDisplay(key))
self.source_list.set_row_data(index,key)
index = index + 1
if index > 0:
@ -159,7 +159,7 @@ class SourceView:
if event.button == 1 and event.type == GDK._2BUTTON_PRESS:
if len(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,
self.update_display_after_edit)
@ -172,7 +172,7 @@ class SourceView:
else:
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):
ans = EditSource.DelSrcQuery(source,self.db,self.update)
@ -182,8 +182,7 @@ class SourceView:
_('Delete Source'),ans.query_response,
_('Keep Source'))
else:
map = self.db.getSourceMap()
del map[source.getId()]
self.db.removeSource(source.getId())
Utils.modified()
self.update(0)
@ -227,7 +226,7 @@ class SourceView:
def on_edit_source_clicked(self,obj):
if len(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,
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_id,GrampsCfg.id_visible)
self.child_list.set_column_visibility(self.c_birth_order,GrampsCfg.index_visible)
import time
t = time.time()
self.apply_filter()
print 'people',time.time() - t
t = time.time()
self.load_family()
print 'family',time.time() -t
t = time.time()
self.source_view.load_sources()
print 'sources',time.time() -t
t = time.time()
self.place_view.load_places()
print 'places',time.time() -t
t = time.time()
self.pedigree_view.load_canvas(self.active_person)
print 'pedegree',time.time() -t
t = time.time()
self.media_view.load_media()
print 'media',time.time() -t
t = time.time()
self.toolbar.set_style(GrampsCfg.toolbar)
def update_display(self,changed):