def close_db(error): """ Closes the database again at the end of the request. Note the 'g' object which makes sure we only operate on the current request. g对象保持每个请求分开.这样在关闭一个数据库连接时,并不会关闭所有数据库连接. :param error: :return: """ if hasattr(g, "sqlite_db"): lendydata.close_db()
def ev_close(self, event=None): data.close_db() self.top.quit()