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