当前位置: 首页>>代码示例>>Python>>正文


Python Factory.maptag方法代码示例

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


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

示例1: __init__

# 需要导入模块: from suds.xsd.sxbuiltin import Factory [as 别名]
# 或者: from suds.xsd.sxbuiltin.Factory import maptag [as 别名]
 def __init__(self, configuration):
     Factory.maptag("decimal", XDecimal)
     self.client = Client(configuration.wsdl)
     credentials = self.create("Credentials")
     credentials.IntegrationID = configuration.integration_id
     credentials.Username = configuration.username
     credentials.Password = configuration.password
     self.plugin = AuthenticatorPlugin(credentials, self.client)
     self.client.set_options(plugins=[self.plugin], port=configuration.port)
     self.logger = getLogger("stamps")
开发者ID:snosrap,项目名称:stamps,代码行数:12,代码来源:services.py

示例2: test_recognize_custom_mapped_builtins

# 需要导入模块: from suds.xsd.sxbuiltin import Factory [as 别名]
# 或者: from suds.xsd.sxbuiltin.Factory import maptag [as 别名]
def test_recognize_custom_mapped_builtins(monkeypatch):
    """User code can register additional XSD built-ins."""
    _monkeypatch_builtin_XSD_type_registry(monkeypatch)
    schema = _create_dummy_schema()
    name = "trla-baba-lan"
    for ns in builtin_namespaces:
        assert not schema.builtin((name, ns))
    Factory.maptag(name, _Dummy)
    for ns in builtin_namespaces:
        assert schema.builtin((name, ns))
开发者ID:codingkevin,项目名称:suds,代码行数:12,代码来源:test_xsd_builtins.py

示例3: test_create_custom_mapped_builtin_type_schema_objects

# 需要导入模块: from suds.xsd.sxbuiltin import Factory [as 别名]
# 或者: from suds.xsd.sxbuiltin.Factory import maptag [as 别名]
def test_create_custom_mapped_builtin_type_schema_objects(xsd_type_name,
        monkeypatch):
    """User code can add or update built-in XSD type registrations."""
    _monkeypatch_builtin_XSD_type_registry(monkeypatch)
    class MockType:
        def __init__(self, schema, name):
            self.schema = schema
            self.name = name
    schema = _Dummy()
    Factory.maptag(xsd_type_name, MockType)
    xsd_object = Factory.create(schema, xsd_type_name)
    assert xsd_object.__class__ is MockType
    assert xsd_object.name == xsd_type_name
    assert xsd_object.schema is schema
开发者ID:codingkevin,项目名称:suds,代码行数:16,代码来源:test_xsd_builtins.py

示例4: test_resolving_builtin_types

# 需要导入模块: from suds.xsd.sxbuiltin import Factory [as 别名]
# 或者: from suds.xsd.sxbuiltin.Factory import maptag [as 别名]
def test_resolving_builtin_types(monkeypatch):
    _monkeypatch_builtin_XSD_type_registry(monkeypatch)
    class MockXInteger(XInteger):
        pass
    Factory.maptag("osama", MockXInteger)

    wsdl = tests.wsdl('<xsd:element name="wu" type="xsd:osama"/>', input="wu")
    client = tests.client_from_wsdl(wsdl)

    element, schema_object = client.sd[0].params[0]
    assert element.name == "wu"
    assert element.type == ("osama", "http://www.w3.org/2001/XMLSchema")
    assert schema_object.__class__ is MockXInteger
    assert schema_object.name == "osama"
    assert schema_object.schema is client.wsdl.schema
开发者ID:ovnicraft,项目名称:suds,代码行数:17,代码来源:test_xsd_builtins.py

示例5: __init__

# 需要导入模块: from suds.xsd.sxbuiltin import Factory [as 别名]
# 或者: from suds.xsd.sxbuiltin.Factory import maptag [as 别名]
 def __init__(self, configuration, wsdl_name, wsdl_version, service_id):
     Factory.maptag("decimal", XDecimal)
     name = "{0}Service_v{1:d}.wsdl".format(wsdl_name, wsdl_version)
     wsdl = os.path.join(configuration.wsdls, name)
     self.client = Client(wsdl)
     self.logger = getLogger("fedex")
     credential = self.create("WebAuthenticationCredential")
     credential.Key = configuration.key
     credential.Password = configuration.password
     self.credentials = self.create("WebAuthenticationDetail")
     self.credentials.UserCredential = credential
     self.client_detail = self.create("ClientDetail")
     self.client_detail.AccountNumber = configuration.account_number
     self.client_detail.MeterNumber = configuration.meter_number
     self.version = self.create("VersionId")
     self.version.ServiceId = service_id
     self.version.Major = wsdl_version
     self.version.Intermediate = 0
     self.version.Minor = 0
开发者ID:shalakhin,项目名称:fedex,代码行数:21,代码来源:commons.py

示例6: test_translation

# 需要导入模块: from suds.xsd.sxbuiltin import Factory [as 别名]
# 或者: from suds.xsd.sxbuiltin.Factory import maptag [as 别名]
def test_translation(monkeypatch):
    """Python <--> XML representation translation on marshall/unmarshall."""
    anObject = _Dummy()
    class MockType(XBuiltin):
        def __init__(self, *args, **kwargs):
            self._mock_translate_log = []
            super(MockType, self).__init__(*args, **kwargs)
        def translate(self, value, topython=True):
            self._mock_translate_log.append((value, topython))
            if topython:
                return anObject
            return "'ollywood"
    _monkeypatch_builtin_XSD_type_registry(monkeypatch)
    Factory.maptag("woof", MockType)

    namespace = "I'm a little tea pot, short and stout..."
    wsdl = testutils.wsdl("""\
      <xsd:element name="wi" type="xsd:woof"/>
      <xsd:element name="wo" type="xsd:woof"/>""", input="wi", output="wo",
        xsd_target_namespace=namespace, operation_name="f")
    client = testutils.client_from_wsdl(wsdl, nosend=True, prettyxml=True)

    # Check suds library's XSD schema input parameter information.
    schema = client.wsdl.schema
    element_in = schema.elements["wi", namespace]
    assert element_in.name == "wi"
    element_out = schema.elements["wo", namespace]
    assert element_out.name == "wo"
    schema_object_in = element_in.resolve()
    schema_object_out = element_out.resolve()
    assert element_in is client.sd[0].params[0][0]
    assert schema_object_in is client.sd[0].params[0][1]
    assert schema_object_in.__class__ is MockType
    assert schema_object_in._mock_translate_log == []
    assert schema_object_out.__class__ is MockType
    assert schema_object_out._mock_translate_log == []

    # Construct operation invocation request - test marshalling.
    request = client.service.f(55)
    assert schema_object_in._mock_translate_log == [(55, False)]
    assert schema_object_out._mock_translate_log == []
    CompareSAX.data2data(request.envelope, """\
<?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
   <Header/>
   <Body>
      <wi xmlns="%s">&apos;ollywood</wi>
   </Body>
</Envelope>""" % (namespace,))

    # Process operation response - test unmarshalling.
    response = client.service.f(__inject=dict(reply=suds.byte_str("""\
<?xml version="1.0"?>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
  <Body>
    <wo xmlns="%s">fri-fru</wo>
  </Body>
</Envelope>""" % (namespace,))))
    assert response is anObject
    assert schema_object_in._mock_translate_log == [(55, False)]
    assert schema_object_out._mock_translate_log == [("fri-fru", True)]
开发者ID:codingkevin,项目名称:suds,代码行数:63,代码来源:test_xsd_builtins.py


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