console/SWSCloudCore/controllers/settings/__init__.py
2016-05-10 02:42:07 +03:00

38 lines
880 B
Python

# coding: utf-8
from SWSCloudCore.models import Settings
class ControllerSettings:
def __init__(self):
pass
def get(self, key=''):
x = Settings.select().where(Settings.key == key)
return x.get().val
def set(self, key, val):
if self.exists(key):
# update
return True
# insert
return True
def create(self, key, val):
x = Settings.create(key=key, val=val)
return x.id
def update(self, key, val):
x = Settings.update(val=val).where(Settings.key == key)
x.execute()
return True
def delete(self, key):
x = Settings.delete().where(Settings.key == key)
x.execute()
return True
def exists(self, key):
if Settings.select().where(Settings.key == key).count() == 0:
return False
return True