def _cleanup_callbacks(self): """ Remove all db callbacks. This is done automatically on destruction of the object, but is normally needed earlier, calling this method does so. Use _change_db method if you need to remove the callbacks because the database has changed """ database = self.callman.database if database.is_open(): #a closed database has disconnected all signals self.callman.disconnect_all() #set a new callback manager self.callman = CallbackManager(database)
def _change_db(self, database): """ Change the database the GUI element works on to database. This removes all callbacks and all registered handles. :param database: the new database to connect to """ dbold = self.callman.database if dbold.is_open(): #a closed database has disconnected all signals self.callman.disconnect_all() #set a new callback manager on new database self.callman = CallbackManager(database) self._connect_db_signals()
def __setup_callbacks(self): self.db.connect("family-add", self._family_add) self.db.connect("family-update", self._family_update) self.db.connect("family-delete", self._family_delete) self.db.connect("person-add", self._person_add) self.db.connect("person-update", self._person_update) self.db.connect("person-delete", self._person_delete) self.db.connect("note-add", self._note_add) self.db.connect("note-update", self._note_update) self.db.connect("note-delete", self._note_delete) # we will also test the CallbackManager by watching a single person self.cm_sigs = [] self.callman = CallbackManager(self.db) self.callman.register_callbacks({ 'person-delete': self._cm_pers_delete, 'person-update': self._cm_pers_update, 'person-add': self._cm_pers_add }) self.callman.connect_all(keys=['person']) self.callman.register_handles( {'person': ['0000000300000003', '0000000700000007']})
def __init__(self, database): self.callman = CallbackManager(database) self._connect_db_signals()