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

Python sudsobject.Factory类代码示例

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

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



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

示例1: process

 def process(self, data, type, history):
     """ process the specified type then process its children """
     if type in history:
         return
     if type.enum():
         return
     history.append(type)
     resolved = type.resolve()
     value = None
     if type.multi_occurrence():
         value = []
     else:
         if len(resolved) > 0:
             if resolved.mixed():
                 value = Factory.property(resolved.name)
                 md = value.__metadata__
                 md.sxtype = resolved
             else:
                 value = Factory.object(resolved.name)
                 md = value.__metadata__
                 md.sxtype = resolved
                 md.ordering = self.ordering(resolved)
     setattr(data, type.name, value)
     if value is not None:
         data = value
     if not isinstance(data, list):
         self.add_attributes(data, resolved)
         for child, ancestry in resolved.children():
             if self.skip_child(child, ancestry):
                 continue
             self.process(data, child, history[:])
开发者ID:dkentw,项目名称:pi-tester,代码行数:31,代码来源:builder.py


示例2: __init__

 def __init__(self, root, definitions):
     """
     @param root: An XML root element.
     @type root: L{Element}
     @param definitions: A definitions object.
     @type definitions: L{Definitions}
     """
     NamedObject.__init__(self, root, definitions)
     self.operations = {}
     for c in root.getChildren('operation'):
         op = SFactory.object('Operation')
         op.name = c.get('name')
         op.tns = definitions.tns
         input = c.getChild('input')
         op.input = input.get('message')
         output = c.getChild('output', default=input)
         if output is None:
             op.output = None
         else:
             op.output = output.get('message')
         faults = []
         for fault in c.getChildren('fault'):
             f = SFactory.object('Operation')
             f.name = fault.get('name')
             f.message = fault.get('message')
             faults.append(f)
         op.faults = faults
         self.operations[op.name] = op
开发者ID:bigbang4u2,项目名称:mywork,代码行数:28,代码来源:wsdl.py


示例3: replycomposite

 def replycomposite(self, rtypes, nodes):
     """
     Construct a I{composite} reply.  This method is called when it has been
     detected that the reply has multiple root nodes.
     @param rtypes: A list of known return I{types}.
     @type rtypes: [L{suds.xsd.sxbase.SchemaObject},...]
     @param nodes: A collection of XML nodes.
     @type nodes: [L{Element},...]
     @return: The I{unmarshalled} composite object.
     @rtype: L{Object},...
     """
     dictionary = {}
     for rt in rtypes:
         dictionary[rt.name] = rt
     unmarshaller = self.unmarshaller()
     composite = Factory.object('reply')
     for node in nodes:
         tag = node.name
         rt = dictionary.get(tag, None)
         if rt is None:
             if node.get('id') is None:
                 raise Exception('<%s/> not mapped to message part' % tag)
             else:
                 continue
         resolved = rt.resolve(nobuiltin=True)
         sobject = unmarshaller.process(node, resolved)
         if rt.unbounded():
             value = getattr(composite, tag, None)
             if value is None:
                 value = []
                 setattr(composite, tag, value)
             value.append(sobject)
         else:
             setattr(composite, tag, sobject)
     return composite
开发者ID:tic-ull,项目名称:defensatfc-proto,代码行数:35,代码来源:binding.py


示例4: create

 def create(self, name):
     """
     create a WSDL type by name
     @param name: The name of a type defined in the WSDL.
     @type name: str
     @return: The requested object.
     @rtype: L{Object}
     """
     timer = metrics.Timer()
     timer.start()
     type = self.resolver.find(name)
     if type is None:
         raise TypeNotFound(name)
     if type.enum():
         result = InstFactory.object(name)
         for e, a in type.children():
             setattr(result, e.name, e.name)
     else:
         try:
             result = self.builder.build(type)
         except Exception as e:
             log.error("create '%s' failed", name, exc_info=True)
             raise BuildError(name, e)
     timer.stop()
     metrics.log.debug('%s created: %s', name, timer)
     return result
开发者ID:pwoolcoc,项目名称:suds-py3k,代码行数:26,代码来源:client.py


示例5: translate

    def translate(self, content):
        """
        Translate using the XSD type information.

        Python I{dict} is translated to a suds object. Most importantly,
        primitive values are translated from python to XML types using the XSD
        type.

        @param content: Content to translate.
        @type content: L{Object}
        @return: self
        @rtype: L{Typed}

        """
        v = content.value
        if v is None:
            return
        if isinstance(v, dict):
            cls = content.real.name
            content.value = Factory.object(cls, v)
            md = content.value.__metadata__
            md.sxtype = content.type
            return
        v = content.real.translate(v, False)
        content.value = v
        return self
开发者ID:JieNanMAXIV,项目名称:edna-mx,代码行数:26,代码来源:literal.py


示例6: postprocess

 def postprocess(self, content):
     """
     Perform final processing of the resulting data structure as follows:
       - Mixed values (children and text) will have a result of the I{content.node}.
       - Simi-simple values (attributes, no-children and text) will have a result of a
          property object.
       - Simple values (no-attributes, no-children with text nodes) will have a string
          result equal to the value of the content.node.getText().
     @param content: The current content being unmarshalled.
     @type content: L{Content}
     @return: The post-processed result.
     @rtype: I{any}
     """
     node = content.node
     if len(node.children) and node.hasText():
         return node
     attributes = AttrList(node.attributes)
     if attributes.rlen() and not len(node.children) and node.hasText():
         p = Factory.property(node.name, node.getText())
         return merge(content.data, p)
     if len(content.data):
         return content.data
     lang = attributes.lang()
     if content.node.isnil():
         return None
     if not len(node.children) and content.text is None:
         if self.nillable(content):
             return None
         else:
             return Text("", lang=lang)
     if isinstance(content.text, str):
         return Text(content.text, lang=lang)
     else:
         return content.text
开发者ID:dilawar,项目名称:moose-gui,代码行数:34,代码来源:core.py


示例7: runTransaction

            def runTransaction(self, **kwargs):  # pylint: disable=unused-argument
                cc_reply_items = {
                    'reasonCode': 100,
                    'amount': unicode(amount),
                    'requestDateTime': '2015-01-01T:00:00:00Z',
                    'reconciliationID': 'efg456'
                }
                items = {
                    'requestID': transaction_id,
                    'decision': decision,
                    'merchantReferenceCode': unicode(basket_id),
                    'reasonCode': 100,
                    'requestToken': 'abc123',
                    'purchaseTotals': Factory.object('PurchaseTotals', {'currency': currency}),
                    'ccCreditReply': Factory.object('CCCreditReply', cc_reply_items)
                }

                return Factory.object('reply', items)
开发者ID:open-craft,项目名称:ecommerce,代码行数:18,代码来源:mixins.py


示例8: start

 def start(self, content):
     """
     Processing on I{node} has started.  Build and return
     the proper object.
     @param content: The current content being unmarshalled.
     @type content: L{Content}
     @return: A subclass of Object.
     @rtype: L{Object}
     """
     content.data = Factory.object(content.node.name)
开发者ID:kennu,项目名称:suds,代码行数:10,代码来源:core.py


示例9: cast

 def cast(self, content):
     """
     Cast the I{untyped} list items found in content I{value}.
     Each items contained in the list is checked for XSD type information.
     Items (values) that are I{untyped}, are replaced with suds objects and
     type I{metadata} is added.
     @param content: The content holding the collection.
     @type content: L{Content}
     @return: self
     @rtype: L{Encoded}
     """
     aty = content.aty[1]
     resolved = content.type.resolve()
     array = Factory.object(resolved.name)
     array.item = []
     query = TypeQuery(aty)
     ref = query.execute(self.schema)
     if ref is None:
         raise TypeNotFound(qref)
     for x in content.value:
         if isinstance(x, (list, tuple)):
             array.item.append(x)
             continue
         if isinstance(x, Object):
             md = x.__metadata__
             md.sxtype = ref
             array.item.append(x)
             continue
         if isinstance(x, dict):
             x = Factory.object(ref.name, x)
             md = x.__metadata__
             md.sxtype = ref
             array.item.append(x)
             continue
         x = Factory.property(ref.name, x)
         md = x.__metadata__
         md.sxtype = ref
         array.item.append(x)
     content.value = array
     return self
开发者ID:BhallaLab,项目名称:moose-gui,代码行数:40,代码来源:encoded.py


示例10: build

 def build(self, name):
     """ build a an object for the specified typename as defined in the schema """
     if isinstance(name, basestring):
         type = self.resolver.find(name)
         if type is None:
             raise TypeNotFound(name)
     else:
         type = name
     cls = type.name
     if type.mixed():
         data = Factory.property(cls)
     else:
         data = Factory.object(cls)
     resolved = type.resolve()
     md = data.__metadata__
     md.sxtype = resolved
     md.ordering = self.ordering(resolved)
     history = []
     self.add_attributes(data, resolved)
     for child, ancestry in type.children():
         if self.skip_child(child, ancestry):
             continue
         self.process(data, child, history[:])
     return data
开发者ID:dkentw,项目名称:pi-tester,代码行数:24,代码来源:builder.py


示例11: add_methods

 def add_methods(self, service):
     """ Build method view for service """
     bindings = {
         'document/literal' : Document(self),
         'rpc/literal' : RPC(self),
         'rpc/encoded' : Encoded(self)
     }
     for p in service.ports:
         binding = p.binding
         ptype = p.binding.type
         operations = p.binding.type.operations.values()
         for name in [op.name for op in operations]:
             m = SFactory.object('Method')
             m.name = name
             m.location = p.location
             m.binding = SFactory.object('binding')
             op = binding.operation(name)
             m.soap = op.soap
             key = '/'.join((op.soap.style, op.soap.input.body.use))
             m.binding.input = bindings.get(key)
             key = '/'.join((op.soap.style, op.soap.output.body.use))
             m.binding.output = bindings.get(key)
             op = ptype.operation(name)
             p.methods[name] = m
开发者ID:bigbang4u2,项目名称:mywork,代码行数:24,代码来源:wsdl.py


示例12: replycomposite

    def replycomposite(self, rtypes, nodes):
        """
        Construct a I{composite} reply.

        Called for replies with multiple output nodes.

        @param rtypes: A list of known return I{types}.
        @type rtypes: [L{suds.xsd.sxbase.SchemaObject},...]
        @param nodes: A collection of XML nodes.
        @type nodes: [L{Element},...]
        @return: The I{unmarshalled} composite object.
        @rtype: L{Object},...

        """
        dictionary = {}
        for rt in rtypes:
            dictionary[rt.name] = rt
        unmarshaller = self.unmarshaller()
        composite = Factory.object("reply")
        for node in nodes:
            tag = node.name
            rt = dictionary.get(tag)
            if rt is None:
                if node.get("id") is None:
                    message = "<%s/> not mapped to message part" % (tag,)
                    raise Exception(message)
                continue
            resolved = rt.resolve(nobuiltin=True)
            sobject = unmarshaller.process(node, resolved)
            value = getattr(composite, tag, None)
            if value is None:
                if rt.multi_occurrence():
                    value = []
                    setattr(composite, tag, value)
                    value.append(sobject)
                else:
                    setattr(composite, tag, sobject)
            else:
                if not isinstance(value, list):
                    value = [value,]
                    setattr(composite, tag, value)
                value.append(sobject)
        return composite
开发者ID:EASYMARKETING,项目名称:suds-jurko,代码行数:43,代码来源:binding.py


示例13: header

 def header(self, definitions, parent, root):
     """ add the input/output header properties """
     if root is None:
         return
     header = SFactory.object('Header')
     parent.headers.append(header)
     header.use = root.get('use', default='literal')
     ns = root.get('namespace')
     if ns is None:
         header.namespace = definitions.tns
     else:
         prefix = root.findPrefix(ns, 'h0')
         header.namespace = (prefix, ns)
     msg = root.get('message')
     if msg is not None:
         header.message = msg
     part = root.get('part')
     if part is not None:
         header.part = part
开发者ID:bigbang4u2,项目名称:mywork,代码行数:19,代码来源:wsdl.py


示例14: start

 def start(self, content):
     #
     # Resolve to the schema type; build an object and setup metadata.
     #
     if content.type is None:
         found = self.resolver.find(content.node)
         if found is None:
             log.error(self.resolver.schema)
             raise TypeNotFound(content.node.qname())
         content.type = found
     else:
         known = self.resolver.known(content.node)
         frame = Frame(content.type, resolved=known)
         self.resolver.push(frame)
     resolved = self.resolver.top().resolved
     cls_name = resolved.name
     if cls_name is None:
         cls_name = content.node.name
     content.data = Factory.object(cls_name)
     md = content.data.__metadata__
     md.sxtype = content.type
开发者ID:bigbang4u2,项目名称:mywork,代码行数:21,代码来源:typed.py


示例15: add_operations

 def add_operations(self, root, definitions):
     """ Add <operation/> children """
     dsop = Element('operation', ns=soapns)
     for c in root.getChildren('operation'):
         op = SFactory.object('Operation')
         op.name = c.get('name')
         sop = c.getChild('operation', default=dsop)
         soap = SFactory.object('soap')
         soap.action = '"%s"' % sop.get('soapAction', default='')
         soap.style = sop.get('style', default=self.soap.style)
         soap.input = SFactory.object('Input')
         soap.input.body = SFactory.object('Body')
         soap.input.headers = []
         soap.output = SFactory.object('Output')
         soap.output.body = SFactory.object('Body')
         soap.output.headers = []
         op.soap = soap
         input = c.getChild('input')
         if input is None:
             input = Element('input', ns=wsdlns)
         body = input.getChild('body')
         self.body(definitions, soap.input.body, body)
         for header in input.getChildren('header'):
             self.header(definitions, soap.input, header)
         output = c.getChild('output')
         if output is None:
             output = Element('output', ns=wsdlns)
         body = output.getChild('body')
         self.body(definitions, soap.output.body, output)
         for header in output.getChildren('header'):
             self.header(definitions, soap.output, header)
         faults = []
         for fault in c.getChildren('fault'):
             fault = fault.getChild('fault')
             if fault is None:
                 continue
             f = SFactory.object('Fault')
             f.name = fault.get('name')
             f.use = fault.get('use', default='literal')
             faults.append(f)
         soap.faults = faults
         self.operations[op.name] = op
开发者ID:bigbang4u2,项目名称:mywork,代码行数:42,代码来源:wsdl.py


示例16: start

 def start(self, content):
     """ 
     Resolve to the schema type; build an object and setup metadata.
     @param content: The current content being unmarshalled.
     @type content: L{Content}
     @return: A subclass of Object.
     @rtype: L{Object}
     """
     if content.type is None:
         found = self.resolver.find(content.node)
         if found is None:
             log.error(self.resolver.schema)
             raise TypeNotFound(content.node.qname())
         content.type = found
     else:
         frame = Frame(content.type)
         self.resolver.push(frame)
     cls_name = content.type.name
     if cls_name is None:
         cls_name = content.node.name
     content.data = Factory.object(cls_name)
     md = content.data.__metadata__
     md.sxtype = content.type
开发者ID:tic-ull,项目名称:defensatfc-proto,代码行数:23,代码来源:unmarshaller.py


示例17: create_suds_type

def create_suds_type(name='FakeSudsObject', **kwargs):
    return Factory.object(name, kwargs)
开发者ID:jamesls,项目名称:labmanager-shell,代码行数:2,代码来源:test_api.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python sudsobject.Metadata类代码示例发布时间:2022-05-27
下一篇:
Python sudsobject.Facade类代码示例发布时间: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