def METHOD_NAME(cls, name, autoflush=True, for_update=False):
    q = meta.Session.query(cls).autoflush(autoflush
        ).filter_by(name=name)
    if for_update:
        q = q.with_for_update()
    return q.first()