@staticmethod
    def __get_request_data(app, request, session):
        try:
            parameters = request.json or {}
        except:
            parameters = {"INVALID_JSON": request.data}

        form = request.form.to_dict(flat=False)

        for key, value in form.iteritems():
            if len(value) == 1:
                parameters[key] = value[0]
            else:
                parameters[key] = value

        files = request.files.to_dict(flat=False)

        for key, value in files.iteritems():
            if len(value) == 1:
                parameters[key] = value[0].filename
            else:
                parameters[key] = [file.filename for file in value]

        if request.cookies:
            cookies = Exceptional.__filter(app, request.cookies,
                    "EXCEPTIONAL_COOKIE_FILTER")
            headers = Headers(request.headers)  # Get a mutable dictionary.
            cookie = SimpleCookie()

            for key, value in cookies.iteritems():
                cookie[key] = value

            headers["Cookie"] = cookie.output(header='', sep=';').strip()
        else:
            headers = request.headers

        return {
            "session": Exceptional.__filter(app, session,
                "EXCEPTIONAL_SESSION_FILTER"),
            "remote_ip": request.remote_addr,
            "parameters": Exceptional.__filter(app, parameters,
                "EXCEPTIONAL_PARAMETER_FILTER"),
            "action": request.endpoint.split('.', 1)[-1] if request.endpoint
                else None,
            "url": request.url,
            "request_method": request.method,
            "controller": request.blueprint if hasattr(request, "blueprint")
                else request.module,
            "headers": Exceptional.__filter(app, headers,
                "EXCEPTIONAL_HEADER_FILTER")
        }
Helps you easily register all "public" callable attributes of an object.
dataset/ETHPy150Open jzempel/flask-exceptional/flask_exceptional.py/Exceptional.__get_request_data--crossover with--dataset/ETHPy150Open spantaleev/sijax-python/sijax/plugin/comet/__init__.py/register_comet_object