當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。