コード例 #1
0
ファイル: base.py プロジェクト: carriercomm/solitude
    def process(self, serial_class, form_class, request):
        form = form_class(request.DATA)
        if not form.is_valid():
            raise ProcessError(Response(format_form_errors(form), status=400))

        serial = serial_class(data=request.DATA)
        if not serial.is_valid():
            raise ProcessError(Response(serial.errors, status=400))

        return serial, form
コード例 #2
0
    def process(self, serial_class, form_class, request):
        form = form_class(request.DATA)
        if not form.is_valid():
            raise ProcessError(Response(format_form_errors(form), status=400))

        serial = serial_class(data=request.DATA)
        if not serial.is_valid():
            raise ProcessError(Response(serial.errors, status=400))

        return serial, form
コード例 #3
0
ファイル: base.py プロジェクト: carriercomm/solitude
    def client(self, method, data, raise_on=None, client=None):
        """
        Client to call the bango client and process errors in a way that
        is relevant to the form. If you pass in a list of errors, these will
        be treated as errors the callee is going to deal with and will not
        be returning ImmediateHttpResponses. Instead the callee will have to
        cope with these BangoAnticipatedErrors as appropriate.

        You can optionally pass in a client to override the default.
        """
        raise_on = raise_on or []
        try:
            return getattr(client or get_client(), method)(data)
        except BangoUnanticipatedError, exc:
            # It was requested that the error that was passed in
            # was actually anticipated, so let's raise that type of error.
            if exc.id in raise_on:
                raise BangoAnticipatedError(exc.id, exc.message)

            res = self.client_errors(exc)
            raise BangoImmediateError(format_form_errors(res))
コード例 #4
0
    def client(self, method, data, raise_on=None, client=None):
        """
        Client to call the bango client and process errors in a way that
        is relevant to the form. If you pass in a list of errors, these will
        be treated as errors the callee is going to deal with and will not
        be returning ImmediateHttpResponses. Instead the callee will have to
        cope with these BangoAnticipatedErrors as appropriate.

        You can optionally pass in a client to override the default.
        """
        raise_on = raise_on or []
        try:
            return getattr(client or get_client(), method)(data)
        except BangoUnanticipatedError, exc:
            # It was requested that the error that was passed in
            # was actually anticipated, so let's raise that type of error.
            if exc.id in raise_on:
                raise BangoAnticipatedError(exc.id, exc.message)

            res = self.client_errors(exc)
            raise BangoImmediateError(format_form_errors(res))
コード例 #5
0
ファイル: base.py プロジェクト: carriercomm/solitude
 def form_errors(self, forms):
     return Response(format_form_errors(forms), status=400)
コード例 #6
0
 def form_errors(self, forms):
     return Response(format_form_errors(forms), status=400)