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
评论列表
文章目录