kvstore: Allow module to be imported before Django init

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa 2020-09-02 15:30:43 -07:00 committed by Veiko Aasa
parent 495f93af24
commit 3375ba7d19
No known key found for this signature in database
GPG Key ID: 478539CAE680674E

View File

@ -3,11 +3,10 @@
Simple key/value store using Django models
"""
from plinth.models import KVStore
def get(key):
"""Return the value of a key"""
from plinth.models import KVStore
# pylint: disable-msg=E1101
return KVStore.objects.get(pk=key).value
@ -22,10 +21,12 @@ def get_default(key, default_value):
def set(key, value): # pylint: disable-msg=W0622
"""Store the value of a key"""
from plinth.models import KVStore
store = KVStore(key=key, value=value)
store.save()
def delete(key):
"""Delete a key"""
from plinth.models import KVStore
return KVStore.objects.get(key=key).delete()