• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python fault.Fault类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中spyne.model.fault.Fault的典型用法代码示例。如果您正苦于以下问题:Python Fault类的具体用法?Python Fault怎么用?Python Fault使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Fault类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self):
        # TODO: self.transport.http.resp_code = HTTP_401

        Fault.__init__(self,
                faultcode='Client.AuthorizationError',
                faultstring='You are not authorized to access this resource.'
            )
开发者ID:66ru,项目名称:spyne,代码行数:7,代码来源:server_soap.py


示例2: __init__

    def __init__(self, username):
        # TODO: self.transport.http.resp_code = HTTP_401

        Fault.__init__(
            self,
            faultcode='Client.LoginUnsupported',
            faultstring='Login Unsupported for non free user  %r' % username)
开发者ID:dddanmar,项目名称:PythonSonosServerExample,代码行数:7,代码来源:Sonos_Soap.py


示例3: __init__

    def __init__(self, obj, custom_msg='The value %r could not be validated.'):
        s = repr(obj)

        if len(s) > MAX_STRING_FIELD_LENGTH:
            s = s[:MAX_STRING_FIELD_LENGTH] + "(...)"

        Fault.__init__(self, 'Client.ValidationError', custom_msg % s)
开发者ID:amgibson,项目名称:spyne,代码行数:7,代码来源:error.py


示例4: __init__

 def __init__(self):
     Fault.__init__(self,
             faultcode="Documented",
             faultstring="A documented fault",
             faultactor='http://faultactor.example.com',
             detail=etree.Element('something')
         )
开发者ID:66ru,项目名称:spyne,代码行数:7,代码来源:_service.py


示例5: serialize

    def serialize(self, ctx, message):
        assert message in (self.REQUEST, self.RESPONSE)

        self.event_manager.fire_event('before_serialize', ctx)

        if ctx.out_error is not None:
            ctx.out_document = [Fault.to_dict(ctx.out_error.__class__,
                                                                 ctx.out_error)]

        else:
            # get the result message
            if message is self.REQUEST:
                out_type = ctx.descriptor.in_message
            elif message is self.RESPONSE:
                out_type = ctx.descriptor.out_message
            if out_type is None:
                return

            out_type_info = out_type._type_info

            # instantiate the result message
            out_instance = out_type()

            # assign raw result to its wrapper, result_message
            for i in range(len(out_type_info)):
                attr_name = out_type_info.keys()[i]
                setattr(out_instance, attr_name, ctx.out_object[i])

            ctx.out_document = self._object_to_doc(out_type, out_instance),

            self.event_manager.fire_event('after_serialize', ctx)
开发者ID:dmugtasimov,项目名称:spyne,代码行数:31,代码来源:dictdoc.py


示例6: serialize

    def serialize(self, ctx, message):
        assert message in (self.REQUEST, self.RESPONSE)

        self.event_manager.fire_event('before_serialize', ctx)

        if ctx.out_error is not None:
            ctx.out_document = [
                [MessagePackRpc.MSGPACK_RESPONSE, 0,
                           Fault.to_dict(ctx.out_error.__class__, ctx.out_error)]
            ]
            return

        # get the result message
        if message is self.REQUEST:
            out_type = ctx.descriptor.in_message
            msgtype = MessagePackRpc.MSGPACK_REQUEST
            method_name_or_error = ctx.descriptor.operation_name

        elif message is self.RESPONSE:
            out_type = ctx.descriptor.out_message
            msgtype = MessagePackRpc.MSGPACK_RESPONSE
            method_name_or_error = None

        else:
            raise Exception("what?")

        if out_type is None:
            return

        out_type_info = out_type._type_info

        # instantiate the result message
        out_instance = out_type()

        # assign raw result to its wrapper, result_message
        for i, (k, v) in enumerate(out_type_info.items()):
            attr_name = k
            out_instance._safe_set(attr_name, ctx.out_object[i], v)

        # transform the results into a dict:
        if out_type.Attributes.max_occurs > 1:
            params = (self._to_dict_value(out_type, inst, set())
                                                       for inst in out_instance)
        else:
            params = self._to_dict_value(out_type, out_instance, set())

        ctx.out_document = [[msgtype, 0, method_name_or_error, params]]

        self.event_manager.fire_event('after_serialize', ctx)
开发者ID:ashleysommer,项目名称:spyne,代码行数:49,代码来源:msgpack.py


示例7: serialize

    def serialize(self, ctx, message):
        assert message in (self.REQUEST, self.RESPONSE)

        self.event_manager.fire_event('before_serialize', ctx)

        if ctx.out_error is not None:
            ctx.out_document = [MessagePackRpc.MSGPACK_RESPONSE, 0,
                         Fault.to_dict(ctx.out_error.__class__,  ctx.out_error)]

        else:
            # get the result message
            if message is self.REQUEST:
                out_type = ctx.descriptor.in_message
            elif message is self.RESPONSE:
                out_type = ctx.descriptor.out_message

            if out_type is None:
                return

            out_type_info = out_type._type_info

            # instantiate the result message
            out_instance = out_type()

            # assign raw result to its wrapper, result_message
            for i in range(len(out_type_info)):
                attr_name = out_type_info.keys()[i]
                setattr(out_instance, attr_name, ctx.out_object[i])

            # transform the results into a dict:
            if out_type.Attributes.max_occurs > 1:
                ctx.out_document = [[MessagePackRpc.MSGPACK_RESPONSE, 0, None,
                        (self._to_value(out_type, inst)
                                                      for inst in out_instance)
                    ]]
            else:
                ctx.out_document = [[MessagePackRpc.MSGPACK_RESPONSE, 0, None,
                                        self._to_value(out_type, out_instance),
                                   ]]

            self.event_manager.fire_event('after_serialize', ctx)
开发者ID:buldi,项目名称:spyne,代码行数:41,代码来源:msgpack.py


示例8: __init__

 def __init__(self):
     Fault.__init__(
         self,
         faultcode="ElbeAuthenticationFailed",
         faultstring="Authentication Failed")
开发者ID:Linutronix,项目名称:elbe,代码行数:5,代码来源:faults.py


示例9: serialize

    def serialize(self, ctx, message):
        assert message in (self.REQUEST, self.RESPONSE)

        self.event_manager.fire_event('before_serialize', ctx)

        # construct the soap response, and serialize it
        nsmap = self.app.interface.nsmap
        ctx.out_document = {
            "ver": self.version,
        }
        if ctx.out_error is not None:
            ctx.out_document[self.FAULT] = Fault.to_dict(Fault, ctx.out_error)

        else:
            if message is self.REQUEST:
                header_message_class = ctx.descriptor.in_header
                body_message_class = ctx.descriptor.in_message

            elif message is self.RESPONSE:
                header_message_class = ctx.descriptor.out_header
                body_message_class = ctx.descriptor.out_message

            # assign raw result to its wrapper, result_message
            out_type_info = body_message_class._type_info
            out_object = body_message_class()

            keys = iter(out_type_info)
            values = iter(ctx.out_object)
            while True:
                try:
                    k = keys.next()
                except StopIteration:
                    break
                try:
                    v = values.next()
                except StopIteration:
                    v = None

                setattr(out_object, k, v)

            ctx.out_document[self.BODY] = ctx.out_body_doc = \
                            self._object_to_doc(body_message_class, out_object)

            # header
            if ctx.out_header is not None and header_message_class is not None:
                if isinstance(ctx.out_header, (list, tuple)):
                    out_headers = ctx.out_header
                else:
                    out_headers = (ctx.out_header,)

                ctx.out_header_doc = out_header_doc = []

                for header_class, out_header in zip(header_message_class,
                                                                   out_headers):
                    out_header_doc.append(self._object_to_doc(header_class,
                                                                    out_header))

                if len(out_header_doc) > 1:
                    ctx.out_document[self.HEAD] = out_header_doc
                else:
                    ctx.out_document[self.HEAD] = out_header_doc[0]

        self.event_manager.fire_event('after_serialize', ctx)
开发者ID:harshil07,项目名称:spyne,代码行数:63,代码来源:json.py


示例10: __init__

 def __init__(self, faultstring):
     Fault.__init__(self, 'Client.ValidationError',
                     'The value %r could not be validated.' % faultstring)
开发者ID:66ru,项目名称:spyne,代码行数:3,代码来源:error.py


示例11: __init__

 def __init__(self, fault_object,
          fault_string="You do not have permission to access this resource"):
     Fault.__init__(self, 'Client.InvalidCredentialsError', fault_string)
开发者ID:dmugtasimov,项目名称:spyne,代码行数:3,代码来源:error.py


示例12: __init__

 def __init__(self, faultstring):
     Fault.__init__(self, 'Client.SchemaValidationError', faultstring)
开发者ID:drowolath,项目名称:spyne,代码行数:2,代码来源:_base.py


示例13: __init__

 def __init__(self):
     Fault.__init__(self,
             faultcode="Documented",
             faultstring="A documented fault",
             faultactor='http://faultactor.example.com',
         )
开发者ID:shaung,项目名称:spyne,代码行数:6,代码来源:_service.py


示例14: __init__

 def __init__(self, data=None):
     Fault.__init__(self, "Client.MessagePackDecodeError", data)
开发者ID:shaung,项目名称:spyne,代码行数:2,代码来源:__init__.py



注:本文中的spyne.model.fault.Fault类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python primitive.NATIVE_MAP类代码示例发布时间:2022-05-27
下一篇:
Python complex.ComplexModel类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap