def connect_objects(self, what, what_id, to, to_id): # # what and to are table names of needed models # what_wrapper = None to_wrapper = None for wrapper in ModelWrapper.__subclasses__(): if wrapper.model_class.__tablename__ == what: what_model = wrapper.model_class.query.filter_by(id=what_id).all()[0] what_wrapper = wrapper(what_model) if wrapper.model_class.__tablename__ == to: to_model = wrapper.model_class.query.filter_by(id=to_id).all()[0] to_wrapper = wrapper(to_model) ConnectionManager.connect(what_wrapper, to_wrapper)