def METHOD_NAME(self, search_query):
    def g():
        encoder = APIEncoder()
        with session_scope(self.account_id) as db_session:
            yield encoder.cereal(
                self.search_messages(db_session, search_query)
            ) + "\n"
    return g