def update(self, request, key_value_id=None):
        ###TODO This whole method is not functioning correctly. Just for version 2. Not getting the system_id or truth_id from the poster firefox plugin
        if 'system_id' in request.POST:
            n = None
            found = False
            post_key = request.POST.get('key')
            post_value = request.POST.get('value')
            system_id = request.POST.get('system_id')
            key_validated, validation_error_string = self.validate(post_key, post_value) 
            if re.search('^nic\.(\d+)\.ipv4_address', str(post_key).strip() ):
                try:
                    acl = KeyValueACL(request)
                    system = System.objects.get(id=system_id)
                    acl.check_ip_not_exist_other_system(system, post_value)
                except Exception, e:
                    resp = rc.FORBIDDEN
                    resp.write(e)
                    return resp
            if key_validated is False:
                resp = rc.FORBIDDEN
                resp.write('Validation Failed for %s %s' % (request.POST['key'], validation_error_string) )
                return resp

            try:
                n = KeyValue.objects.get(id=key_value_id,key=request.POST['key'])
                system = System.objects.get(id=request.POST['system_id'])
                found = True
            except Exception, e:
                #print e
                found = False

            if found is False:
                try:
                    system = System.objects.get(id=request.POST['system_id'])
                    n = KeyValue.objects.get(obj=system,key=request.POST['key'])
                    found = True
                except:
                    found = False

            if found is False:
                resp = rc.NOT_FOUND
                resp.write('Neither system_id or truth_id found')
                return resp

            if n is not None:
                n.obj = system
            if 'value' in request.POST and n is not None:
                n.value = request.POST['value']
            if n is not None:
                try:
                    n.save()
                    resp = rc.ALL_OK
                    resp.write('json = {"id":%i}' % (n.id))
                except:
                    resp = rc.NOT_FOUND
                    resp.write('Unable to Create Key/Value Pair')
                return resp
        elif 'truth_id' in request.POST or 'truth_id' in request.PUT:
            try:
                truth = Truth.objects.get(name=key_value_id)
                n = TruthKeyValue.objects.get(truth=truth,key=request.POST['key'])
                if 'value' in request.POST:
                    n.value = request.POST['value']
            except:
                pass
            try:
                n.save()
                resp = rc.ALL_OK
                resp.write('json = {"id":%i}' % (n.id))
            except Exception, e:
                resp = rc.NOT_FOUND
                resp.write(e % 'Unable to Update Key/Value Pair %s')
            return resp
        else:
            resp = rc.NOT_FOUND
            resp.write('Neither system_id or truth_id found')
            return resp
dataset/ETHPy150Open mozilla/inventory/api_v2/keyvalue_handler.py/KeyValueHandler.update/swapped operands of `%`