def clear_lock(key): try: obj = Locks.get(Locks.title == key) obj.delete_instance() return True except Locks.DoesNotExist: return False
def lock_obj(key, val): try: lk = Locks() lk.title = key lk.value = val lk.save() return val except BaseException: obj = Locks.get(Locks.title == key) return obj.value
def get_lock(key): try: obj = Locks.get(Locks.title == key) return obj.value except Locks.DoesNotExist: return False