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 authored and Veiko Aasa committed 2020-09-04 16:32:31 +03:00
1 parent 495f93af24
commit 3375ba7d19
1 file changed
+3 -2
+3 -2
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()