Ejemplo n.º 1
0
    def schema_validation_error_to_parent(self, ctx, cls, inst, parent, ns):
        tag_name = "{%s}Fault" % self.ns_soap_env

        subelts = [
            E("{%s}Reason" % self.soap_env, inst.faultstring),
            E("{%s}Role" % self.soap_env, inst.faultactor),
        ]

        if isinstance(inst.faultcode, string_types):
            value, faultcodes = self.gen_fault_codes(inst.faultcode)

            code = E("{%s}Code" % self.soap_env)
            code.append(E("{%s}Value" % self.soap_env, value))

            child_subcode = 0
            for value in faultcodes:
                if child_subcode:
                    child_subcode = self.generate_subcode(value, child_subcode)
                else:
                    child_subcode = self.generate_subcode(value)
            code.append(child_subcode)

            _append(subelts, code)

        _append(subelts, E('{%s}Detail' % self.soap_env, inst.detail))

        return self.gen_members_parent(ctx, cls, inst, parent, tag_name,
                                       subelts)
Ejemplo n.º 2
0
    def _fault_to_parent_impl(self, ctx, cls, inst, parent, ns, subelts, **_):
        tag_name = "{%s}Fault" % self.ns_soap_env

        if isinstance(inst.faultcode, string_types):
            value, faultcodes = self.gen_fault_codes(inst.faultcode)

            code = E("{%s}Code" % self.ns_soap_env)
            code.append(E("{%s}Value" % self.ns_soap_env, value))

            child_subcode = 0
            for value in faultcodes:
                if child_subcode:
                    child_subcode = self.generate_subcode(value, child_subcode)
                else:
                    child_subcode = self.generate_subcode(value)

            if child_subcode == 0:
                child_subcode = self.generate_subcode(value)

            code.append(child_subcode)

            _append(subelts, code)

        if isinstance(inst.detail, dict):
            _append(subelts, E('{%s}Detail' % self.ns_soap_env, root_dict_to_etree(inst.detail)))

        elif inst.detail is None:
            pass

        else:
            raise TypeError('Fault detail Must be dict, got', type(inst.detail))

        return self.gen_members_parent(ctx, cls, inst, parent, tag_name,
                                                        subelts, add_type=False)
Ejemplo n.º 3
0
    def _fault_to_parent_impl(self, ctx, cls, inst, parent, ns, subelts, **_):
        tag_name = "{%s}Fault" % self.ns_soap_env

        if isinstance(inst.faultcode, string_types):
            value, faultcodes = self.gen_fault_codes(inst.faultcode)

            code = E("{%s}Code" % self.ns_soap_env)
            code.append(E("{%s}Value" % self.ns_soap_env, value))

            child_subcode = False
            for value in faultcodes[::-1]:
                if child_subcode:
                    child_subcode = self.generate_subcode(value, child_subcode)
                else:
                    child_subcode = self.generate_subcode(value)
            if child_subcode != 0:
                code.append(child_subcode)

            _append(subelts, code)

        if isinstance(inst.detail, dict):
            _append(subelts, E('{%s}Detail' % self.ns_soap_env, root_dict_to_etree(inst.detail)))

        elif inst.detail is None:
            pass

        else:
            raise TypeError('Fault detail Must be dict, got', type(inst.detail))

        return self.gen_members_parent(ctx, cls, inst, parent, tag_name,
                                                        subelts, add_type=False)
Ejemplo n.º 4
0
    def schema_validation_error_to_parent(self, ctx, cls, inst, parent, ns):
        tag_name = "{%s}Fault" % self.ns_soap_env

        subelts = [
            E("{%s}Reason" % self.soap_env, inst.faultstring),
            E("{%s}Role" % self.soap_env, inst.faultactor),
        ]

        if isinstance(inst.faultcode, string_types):
            value, faultcodes  = self.gen_fault_codes(inst.faultcode)

            code = E("{%s}Code" % self.soap_env)
            code.append(E("{%s}Value" % self.soap_env, value))

            child_subcode = 0
            for value in faultcodes:
                if child_subcode:
                    child_subcode = self.generate_subcode(value, child_subcode)
                else:
                    child_subcode = self.generate_subcode(value)
            code.append(child_subcode)

            _append(subelts, code)

        _append(subelts, E('{%s}Detail' % self.soap_env, inst.detail))

        return self.gen_members_parent(ctx, cls, inst, parent, tag_name, subelts)
Ejemplo n.º 5
0
    def fault_to_parent(self, ctx, cls, inst, parent, ns, *args, **kwargs):
        tag_name = "{%s}Fault" % self.ns_soap_env

        subelts = [
            E("{%s}Reason" % self.soap_env, inst.faultstring),
            E("{%s}Role" % self.soap_env, inst.faultactor),
        ]

        if isinstance(inst.faultcode, string_types):
            value, faultcodes  = self.gen_fault_codes(inst.faultcode)

            code = E("{%s}Code" % self.soap_env)
            code.append(E("{%s}Value" % self.soap_env, value))

            child_subcode = 0
            for value in faultcodes:
                if child_subcode:
                    child_subcode = self.generate_subcode(value, child_subcode)
                else:
                    child_subcode = self.generate_subcode(value)
            code.append(child_subcode)

            _append(subelts, code)

        if isinstance(inst.detail, dict):
            _append(subelts, E('{%s}Detail' % self.soap_env, root_dict_to_etree(inst.detail)))

        elif inst.detail is None:
            raise TypeError('Fault detail Must be dict, got', type(inst.detail))
        else:
            raise TypeError('Fault detail Must be dict, got', type(inst.detail))

        return self.gen_members_parent(ctx, cls, inst, parent, tag_name, subelts)
Ejemplo n.º 6
0
Archivo: soap12.py Proyecto: hozn/spyne
    def fault_to_parent(self, ctx, cls, inst, parent, ns, *args, **kwargs):
        tag_name = "{%s}Fault" % self.ns_soap_env

        reason = E("{%s}Reason" % self.ns_soap_env)
        reason.append(E("{%s}Text" % self.ns_soap_env, inst.faultstring,
                        **{'{%s}lang' % NS_XML: inst.lang}))

        subelts = [
            reason,
            E("{%s}Role" % self.ns_soap_env, inst.faultactor),
        ]

        if isinstance(inst.faultcode, string_types):
            value, faultcodes  = self.gen_fault_codes(inst.faultcode)

            code = E("{%s}Code" % self.ns_soap_env)
            code.append(E("{%s}Value" % self.ns_soap_env, value))

            child_subcode = 0
            for value in faultcodes:
                if child_subcode:
                    child_subcode = self.generate_subcode(value, child_subcode)
                else:
                    child_subcode = self.generate_subcode(value)
            code.append(child_subcode)

            _append(subelts, code)

        if isinstance(inst.detail, dict):
            _append(subelts, E('{%s}Detail' % self.ns_soap_env, root_dict_to_etree(inst.detail)))

        elif inst.detail is None:
            pass
        else:
            raise TypeError('Fault detail Must be dict, got', type(inst.detail))

        return self.gen_members_parent(ctx, cls, inst, parent, tag_name,
                                                        subelts, add_type=False)