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


Python XmlSchema.get_interface_document方法代码示例

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


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

示例1: get_schema_documents

# 需要导入模块: from spyne.interface.xml_schema import XmlSchema [as 别名]
# 或者: from spyne.interface.xml_schema.XmlSchema import get_interface_document [as 别名]
def get_schema_documents(models, default_namespace=None):
    '''Returns the schema documents in a dict whose keys are namespace prefixes
    and values are Element objects.

    :param models: A list of spyne.model classes that will be represented in
                   the schema.

    '''

    if default_namespace is None:
        default_namespace = models[0].get_namespace()

    fake_app = FakeApplication()
    fake_app.tns = default_namespace
    fake_app.services = []

    interface = Interface(fake_app)
    for m in models:
        interface.add_class(m)
    interface.populate_interface(fake_app)

    document = XmlSchema(interface)
    document.build_interface_document()

    return document.get_interface_document()
开发者ID:Bluehorn,项目名称:spyne,代码行数:27,代码来源:xml.py

示例2: _build_xml_data_test_schema

# 需要导入模块: from spyne.interface.xml_schema import XmlSchema [as 别名]
# 或者: from spyne.interface.xml_schema.XmlSchema import get_interface_document [as 别名]
    def _build_xml_data_test_schema(self, custom_root):
        tns = 'kickass.ns'

        class ProductEdition(ComplexModel):
            __namespace__ = tns
            id = XmlAttribute(Uuid)
            if custom_root:
                name = XmlData(Uuid)
            else:
                name = XmlData(Unicode)

        class Product(ComplexModel):
            __namespace__ = tns
            id = XmlAttribute(Uuid)
            edition = ProductEdition

        class ExampleService(ServiceBase):
            @rpc(Product, _returns=Product)
            def say_my_uuid(ctx, product):
                pass

        app = Application([ExampleService],
            tns='kickass.ns',
            in_protocol=Soap11(validator='lxml'),
            out_protocol=Soap11()
        )

        schema = XmlSchema(app.interface)
        schema.build_interface_document()
        schema.build_validation_schema()

        doc = schema.get_interface_document()['tns']
        print(etree.tostring(doc, pretty_print=True))
        return schema
开发者ID:ashleysommer,项目名称:spyne,代码行数:36,代码来源:test_xml_schema.py

示例3: _write_xsd

# 需要导入模块: from spyne.interface.xml_schema import XmlSchema [as 别名]
# 或者: from spyne.interface.xml_schema.XmlSchema import get_interface_document [as 别名]
def _write_xsd(config):
    from lxml import etree

    from spyne.interface.xml_schema import XmlSchema
    from spyne.util.appreg import applications

    for (tns, name), appdata in applications.items():
        xsd = XmlSchema(appdata.app.interface)
        xsd.build_interface_document()
        schemas = xsd.get_interface_document()

        dir_name = join(config.write_xsd, 'schema.%s' % name)

        try:
            os.makedirs(dir_name)
        except OSError:
            pass

        for k, v in schemas.items():
            file_name = os.path.join(dir_name, "%s.xsd" % k)

            try:
                with open(file_name, 'wb') as f:
                    etree.ElementTree(v).write(f, pretty_print=True)

            except Exception as e:
                print("Error:", e)
                return -1

            print("written",file_name, "for ns", appdata.app.interface.nsmap[k])

    return True  # to force exit
开发者ID:cemrecan,项目名称:neurons,代码行数:34,代码来源:main.py

示例4: test_binary_encodings

# 需要导入模块: from spyne.interface.xml_schema import XmlSchema [as 别名]
# 或者: from spyne.interface.xml_schema.XmlSchema import get_interface_document [as 别名]
    def test_binary_encodings(self):
        class Product(ComplexModel):
            __namespace__ = 'some_ns'

            hex = ByteArray(encoding='hex')
            base64_1 = ByteArray(encoding='base64')
            base64_2 = ByteArray

        class SomeService(ServiceBase):
            @rpc(Product, _returns=Product)
            def echo_product(ctx, product):
                logging.info('edition_id: %r', product.edition_id)
                return product

        app = Application([SomeService],
            tns='some_ns',
            in_protocol=Soap11(validator='lxml'),
            out_protocol=Soap11()
        )

        _ns = {'xs': NS_XSD}
        pref_xs = ns.PREFMAP[NS_XSD]
        xs = XmlSchema(app.interface)
        xs.build_interface_document()
        elt = xs.get_interface_document()['tns'].xpath(
                    '//xs:complexType[@name="Product"]',
                    namespaces=_ns)[0]

        assert elt.xpath('//xs:element[@name="base64_1"]/@type',
                            namespaces=_ns)[0] == '%s:base64Binary' % pref_xs
        assert elt.xpath('//xs:element[@name="base64_2"]/@type',
                            namespaces=_ns)[0] == '%s:base64Binary' % pref_xs
        assert elt.xpath('//xs:element[@name="hex"]/@type',
                            namespaces=_ns)[0] == '%s:hexBinary' % pref_xs
开发者ID:ashleysommer,项目名称:spyne,代码行数:36,代码来源:test_xml_schema.py

示例5: _test_xml_data

# 需要导入模块: from spyne.interface.xml_schema import XmlSchema [as 别名]
# 或者: from spyne.interface.xml_schema.XmlSchema import get_interface_document [as 别名]
    def _test_xml_data(self):
        tns = 'kickass.ns'
        class ProductEdition(ComplexModel):
            __namespace__ = tns
            id = XmlAttribute(Uuid)
            name = XmlData(Unicode)

        class Product(ComplexModel):
            __namespace__ = tns
            id = XmlAttribute(Uuid)
            edition = ProductEdition
            sample = XmlAttribute(Unicode, attribute_of='edition')

        class ExampleService(ServiceBase):
            @rpc(Product, _returns=Product)
            def say_my_uuid(ctx, product):
                pass

        app = Application([ExampleService],
            tns='kickass.ns',
            in_protocol=Soap11(validator='lxml'),
            out_protocol=Soap11()
        )

        schema = XmlSchema(app.interface)
        schema.build_interface_document()

        doc = schema.get_interface_document()['tns']
        print etree.tostring(doc, pretty_print=True)

        assert len(doc.xpath(
                '/xs:schema/xs:complexType[@name="Product"]'
                                    '/xs:sequence/xs:element[@name="edition"]'
                '/xs:complexType/xs:simpleContent/xs:extension'
                                    '/xs:attribute[@name="id"]'
                ,namespaces={'xs': ns.xsd})) == 1
开发者ID:wirewit,项目名称:spyne,代码行数:38,代码来源:test_xml_schema.py


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