repositories.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:experiment-manager 作者: softfire-eu 项目源码 文件源码
def save(entity, _clazz=None):
    if _clazz:
        if hasattr(entity, 'id'):  # usually id is None so this method acs as normal save
            _id = entity.id
        else:
            _id = entity.name
        try:
            if _id:
                found = find(_clazz, _id)
                if isinstance(found, list):
                    for e in found:
                        delete(e)
                else:
                    if found:
                        delete(found)
        except NoResultFound:
            pass

    with get_db_session() as se:
        se.add(entity)
        se.commit()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号