def get_account(self): account_id = self.session.get('account_id') if account_id: account = Account.get_by_id(account_id) if account and account.is_valid: return account