コード例 #1
0
ファイル: __init__.py プロジェクト: lgtml/pyrollbar
def _build_request_data(request):
    """
    Returns a dictionary containing data from the request.
    Can handle webob or werkzeug-based request objects.
    """

    # webob (pyramid)
    if WebobBaseRequest and isinstance(request, WebobBaseRequest):
        return _build_webob_request_data(request)

    # django
    if DjangoHttpRequest and isinstance(request, DjangoHttpRequest):
        return _build_django_request_data(request)

    # django rest framework
    if RestFrameworkRequest and isinstance(request, RestFrameworkRequest):
        return _build_django_request_data(request)

    # werkzeug (flask)
    if WerkzeugRequest and isinstance(request, WerkzeugRequest):
        return _build_werkzeug_request_data(request)

    if WerkzeugLocalProxy and isinstance(request, WerkzeugLocalProxy):
        actual_request = request._get_current_object()
        return _build_werkzeug_request_data(actual_request)

    # tornado
    if TornadoRequest and isinstance(request, TornadoRequest):
        return _build_tornado_request_data(request)

    # bottle
    if BottleRequest and isinstance(request, BottleRequest):
        return _build_bottle_request_data(request)

    return None
コード例 #2
0
def _build_request_data(request):
    """
    Returns a dictionary containing data from the request.
    Can handle webob or werkzeug-based request objects.
    """

    # webob (pyramid)
    if WebobBaseRequest and isinstance(request, WebobBaseRequest):
        return _build_webob_request_data(request)

    # django
    if DjangoHttpRequest and isinstance(request, DjangoHttpRequest):
        return _build_django_request_data(request)

    # django rest framework
    if RestFrameworkRequest and isinstance(request, RestFrameworkRequest):
        return _build_django_request_data(request)

    # werkzeug (flask)
    if WerkzeugRequest and isinstance(request, WerkzeugRequest):
        return _build_werkzeug_request_data(request)

    if WerkzeugLocalProxy and isinstance(request, WerkzeugLocalProxy):
        actual_request = request._get_current_object()
        return _build_werkzeug_request_data(actual_request)

    # tornado
    if TornadoRequest and isinstance(request, TornadoRequest):
        return _build_tornado_request_data(request)

    # bottle
    if BottleRequest and isinstance(request, BottleRequest):
        return _build_bottle_request_data(request)

    return None
コード例 #3
0
ファイル: __init__.py プロジェクト: svvitale/pyrollbar
def _get_actual_request(request):
    if WerkzeugLocalProxy and isinstance(request, WerkzeugLocalProxy):
        try:
            actual_request = request._get_current_object()
        except RuntimeError:
            return None
        return actual_request
    return request
コード例 #4
0
ファイル: __init__.py プロジェクト: rollbar/pyrollbar
def _get_actual_request(request):
    if WerkzeugLocalProxy and isinstance(request, WerkzeugLocalProxy):
        try:
            actual_request = request._get_current_object()
        except RuntimeError:
            return None
        return actual_request
    return request
コード例 #5
0
def _build_request_data(request):
    """
    Returns a dictionary containing data from the request.
    Can handle webob or werkzeug-based request objects.
    """

    # webob (pyramid)
    if WebobBaseRequest and isinstance(request, WebobBaseRequest):
        return _build_webob_request_data(request)

    # django
    if DjangoHttpRequest and isinstance(request, DjangoHttpRequest):
        return _build_django_request_data(request)

    # django rest framework
    if RestFrameworkRequest and isinstance(request, RestFrameworkRequest):
        return _build_django_request_data(request)

    # werkzeug (flask)
    if WerkzeugRequest and isinstance(request, WerkzeugRequest):
        return _build_werkzeug_request_data(request)

    if WerkzeugLocalProxy and isinstance(request, WerkzeugLocalProxy):
        try:
            actual_request = request._get_current_object()
        except RuntimeError:
            return None
        return _build_werkzeug_request_data(actual_request)

    # tornado
    if TornadoRequest and isinstance(request, TornadoRequest):
        return _build_tornado_request_data(request)

    # bottle
    if BottleRequest and isinstance(request, BottleRequest):
        return _build_bottle_request_data(request)

    # Sanic
    if SanicRequest and isinstance(request, SanicRequest):
        return _build_sanic_request_data(request)

    # Plain wsgi (should be last)
    if isinstance(request, dict) and 'wsgi.version' in request:
        return _build_wsgi_request_data(request)

    return None
コード例 #6
0
ファイル: __init__.py プロジェクト: moonbot/pyrollbar
    def _build_request_data(self, request):
        """
        Returns a dictionary containing data from the request.
        Can handle webob or werkzeug-based request objects.
        """

        # webob (pyramid)
        if WebobBaseRequest and isinstance(request, WebobBaseRequest):
            return self._build_webob_request_data(request)

        # django
        if DjangoHttpRequest and isinstance(request, DjangoHttpRequest):
            return self._build_django_request_data(request)

        # django rest framework
        if RestFrameworkRequest and isinstance(request, RestFrameworkRequest):
            return self._build_django_request_data(request)

        # werkzeug (flask)
        if WerkzeugRequest and isinstance(request, WerkzeugRequest):
            return self._build_werkzeug_request_data(request)

        if WerkzeugLocalProxy and isinstance(request, WerkzeugLocalProxy):
            try:
                actual_request = request._get_current_object()
            except RuntimeError:
                return None
            return self._build_werkzeug_request_data(actual_request)

        # tornado
        if TornadoRequest and isinstance(request, TornadoRequest):
            return self._build_tornado_request_data(request)

        # bottle
        if BottleRequest and isinstance(request, BottleRequest):
            return self._build_bottle_request_data(request)

        # Plain wsgi (should be last)
        if isinstance(request, dict) and 'wsgi.version' in request:
            return self._build_wsgi_request_data(request)

        return None