storage.py 文件源码

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

项目:txt2evernote 作者: Xunius 项目源码 文件源码
def setSettings(self, settings):
        """
        Set multuple settings. Settings must be an instanse dict
        return True if all done
        return False if something wrong
        """
        if not isinstance(settings, dict):
            raise Exception("Wrong settings")

        for key in settings.keys():
            if not settings[key]:
                raise Exception("Wrong setting's item")

            instance = self.session.query(Setting).filter_by(key=key).first()
            if instance:
                instance.value = pickle.dumps(settings[key])
            else:
                instance = Setting(key, pickle.dumps(settings[key]))
                self.session.add(instance)

        self.session.commit()
        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号