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


Python sxbuiltin.Factory类代码示例

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


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

示例1: __init__

 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,代码行数:10,代码来源:services.py

示例2: test_recognize_custom_mapped_builtins

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,代码行数:10,代码来源:test_xsd_builtins.py

示例3: test_create_custom_mapped_builtin_type_schema_objects

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,代码行数:14,代码来源:test_xsd_builtins.py

示例4: test_resolving_builtin_types

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,代码行数:15,代码来源:test_xsd_builtins.py

示例5: execute

 def execute(self, schema):
     """
     Execute this query using the specified schema.
     @param schema: The schema associated with the query.  The schema
         is used by the query to search for items.
     @type schema: L{schema.Schema}
     @return: The item matching the search criteria.
     @rtype: L{sxbase.SchemaObject}
     """
     if schema.builtin(self.ref):
         name = self.ref[0]
         b = Factory.create(schema, name)
         log.debug('%s, found builtin (%s)', self.id, name)
         return b
     result = None
     for d in (schema.elements, schema.types):
         result = d.get(self.ref)
         if self.filter(result):
             result = None
         else:
             break
     if result is None:
         eq = ElementQuery(self.ref)
         eq.history = self.history
         result = eq.execute(schema)
     return self.result(result)
开发者ID:tic-ull,项目名称:defensatfc-proto,代码行数:26,代码来源:query.py

示例6: execute

 def execute(self, schema):
     if schema.builtin(self.ref):
         name = self.ref[0]
         b = Factory.create(schema, name)
         log.debug('%s, found builtin (%s)', self.id, name)
         return b
     result = schema.types.get(self.ref)
     if self.filter(result):
         result = None
     return self.result(result)
开发者ID:mnach,项目名称:suds-py3k,代码行数:10,代码来源:query.py

示例7: __init__

 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,代码行数:19,代码来源:commons.py

示例8: test_translation

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,代码行数:61,代码来源:test_xsd_builtins.py

示例9: test_create_builtin_type_schema_objects

def test_create_builtin_type_schema_objects(xsd_type_name, xsd_type):
    schema = _create_dummy_schema()
    xsd_object = Factory.create(schema, xsd_type_name)
    assert xsd_object.__class__ is xsd_type
    assert xsd_object.name == xsd_type_name
    assert xsd_object.schema is schema
开发者ID:codingkevin,项目名称:suds,代码行数:6,代码来源:test_xsd_builtins.py


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