Parse request endpoint and return (resource, action)

def parse_request():
    """Parse request endpoint and return (resource, action)"""
    find = None
    if request.endpoint is not None:
        find = PATTERN_ENDPOINT.findall(request.endpoint)
    if not find:
        raise ValueError("invalid endpoint %s" % request.endpoint)
    __, resource, action_name = find[0]
    if action_name:
        action = request.method.lower() + "_" + action_name
    else:
        action = request.method.lower()
    return resource, action