mirror of
https://github.com/Hopiu/django-select2.git
synced 2026-03-24 17:10:23 +00:00
29 lines
636 B
Python
29 lines
636 B
Python
# -*- coding:utf-8 -*-
|
|
from __future__ import absolute_import, unicode_literals
|
|
|
|
from .models import KeyMap
|
|
|
|
|
|
class Client(object):
|
|
def set(self, key, value):
|
|
"""
|
|
This method is used to set a new value
|
|
in the db.
|
|
"""
|
|
o = self.get(key)
|
|
if o is None:
|
|
o = KeyMap()
|
|
o.key = key
|
|
|
|
o.value = value
|
|
o.save()
|
|
|
|
def get(self, key):
|
|
"""
|
|
This method is used to retrieve a value
|
|
from the db.
|
|
"""
|
|
try:
|
|
return KeyMap.objects.get(key=key).value
|
|
except KeyMap.DoesNotExist:
|
|
return None
|