def is_valid_key(key, r_type):
    try:
        resource_type.objects.get(key=key)
        return False
    except:
        pass
    try:
        resource_info.objects.get(key=key)
        return False
    except:
        pass
    if (r_type == (- 1)):
        return True
    try:
        if (r_type == s.RESOURCE_TYPE_CUSTOMED):
            resource_customed.objects.get(key=key)
            return False
        elif (r_type == s.RESOURCE_TYPE_TEMPLATED):
            resource_templated.objects.get(key=key)
            return False
        elif (r_type == s.RESOURCE_TYPE_RESTFUL_API):
            resource_restful.objects.get(key=key)
            return False
        elif (r_type == s.RESOURCE_TYPE_IFRAME):
            resource_iframe.objects.get(key=key)
            return False
        elif (r_type == s.RESOURCE_TYPE_SHORT_LINK):
            resource_link.objects.get(key=key)
            return False
        else:
            return False
    except:
        return True
def is_valid_key(key, r_type):
    try:
        resource_type.objects.get(key=key)
        return False
    except:
        pass
    try:
        resource_info.objects.get(key=key)
        return False
    except:
        pass
    if (r_type == (- 1)):
        return True
    try:
        if (r_type == s.RESOURCE_TYPE_CUSTOMED):
            resource_customed.objects.get(key=key)
            return False
        elif (r_type == s.RESOURCE_TYPE_TEMPLATED):
            resource_templated.objects.get(key=key)
            return False
        elif (r_type == s.RESOURCE_TYPE_RESTFUL_API):
            resource_restful.objects.get(key=key)
            return False
        elif (r_type == s.RESOURCE_TYPE_IFRAME):
            resource_iframe.objects.get(key=key)
            return False
        elif (r_type == s.RESOURCE_TYPE_SHORT_LINK):
            resource_link.objects.get(key=key)
            return False
        else:
            return False
    except:
        return True