Fix error when changing database in new locations gramplets

This commit is contained in:
Nick Hall 2016-02-11 19:34:28 +00:00
parent c163bfc18e
commit 382635796b

View File

@ -50,7 +50,6 @@ class Locations(Gramplet, DbGUIElement):
def __init__(self, gui, nav_group=0):
Gramplet.__init__(self, gui, nav_group)
DbGUIElement.__init__(self, self.dbstate.db)
self.db = self.dbstate.db
def init(self):
self.gui.WIDGET = self.build_gui()
@ -96,7 +95,7 @@ class Locations(Gramplet, DbGUIElement):
def update_has_data(self):
active_handle = self.get_active('Place')
if active_handle:
active = self.db.get_place_from_handle(active_handle)
active = self.dbstate.db.get_place_from_handle(active_handle)
self.set_has_data(self.get_has_data(active))
else:
self.set_has_data(False)
@ -112,7 +111,7 @@ class Locations(Gramplet, DbGUIElement):
self.callman.unregister_all()
active_handle = self.get_active('Place')
if active_handle:
active = self.db.get_place_from_handle(active_handle)
active = self.dbstate.db.get_place_from_handle(active_handle)
if active:
self.display_place(active, None, [active_handle])
else:
@ -151,7 +150,7 @@ class Locations(Gramplet, DbGUIElement):
model, iter_ = treeview.get_selection().get_selected()
if iter_:
handle = model.get_value(iter_, 0)
place = self.db.get_place_from_handle(handle)
place = self.dbstate.db.get_place_from_handle(handle)
try:
EditPlace(self.dbstate, self.uistate, [], place)
except WindowActiveError:
@ -173,7 +172,7 @@ class EnclosedBy(Locations):
if placeref.ref in visited:
continue
parent_place = self.db.get_place_from_handle(placeref.ref)
parent_place = self.dbstate.db.get_place_from_handle(placeref.ref)
self.add_place(placeref, parent_place, node, visited)
self.set_has_data(self.model.count > 0)
@ -201,12 +200,12 @@ class Encloses(Locations):
Display the location hierarchy for the active place.
"""
self.callman.register_obj(place)
for link in self.db.find_backlink_handles(place.handle,
include_classes=['Place']):
for link in self.dbstate.db.find_backlink_handles(
place.handle, include_classes=['Place']):
if link[1] in visited:
continue
child_place = self.db.get_place_from_handle(link[1])
child_place = self.dbstate.db.get_place_from_handle(link[1])
placeref = None
for placeref in child_place.get_placeref_list():
if placeref.ref != place.handle:
@ -224,7 +223,7 @@ class Encloses(Locations):
"""
if place is None:
return False
for link in self.db.find_backlink_handles(place.handle,
include_classes=['Place']):
for link in self.dbstate.db.find_backlink_handles(
place.handle, include_classes=['Place']):
return True
return False