本文整理汇总了Python中spyne.interface.xml_schema.XmlSchema类的典型用法代码示例。如果您正苦于以下问题:Python XmlSchema类的具体用法?Python XmlSchema怎么用?Python XmlSchema使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XmlSchema类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _write_xsd
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,代码行数:32,代码来源:main.py
示例2: get_schema_documents
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,代码行数:25,代码来源:xml.py
示例3: test_binary_encodings
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,代码行数:34,代码来源:test_xml_schema.py
示例4: set_app
def set_app(self, value):
ProtocolBase.set_app(self, value)
self.validation_schema = None
if value:
from spyne.interface.xml_schema import XmlSchema
xml_schema = XmlSchema(value.interface)
xml_schema.build_validation_schema()
self.validation_schema = xml_schema.validation_schema
开发者ID:drowolath,项目名称:spyne,代码行数:12,代码来源:_base.py
示例5: __init__
def __init__(self, interface=None, _with_partnerlink=False):
XmlSchema.__init__(self, interface)
self._with_plink = _with_partnerlink
self.port_type_dict = {}
self.service_elt_dict = {}
self.root_elt = None
self.service_elt = None
self.__wsdl = None
self.validation_schema = None
开发者ID:leobispo,项目名称:spyne,代码行数:13,代码来源:wsdl11.py
示例6: get_validation_schema
def get_validation_schema(models, default_namespace=None):
"""Returns the validation schema object for the given models.
: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(default_namespace)
interface = Interface(fake_app)
for m in models:
m.resolve_namespace(m, default_namespace)
interface.add_class(m)
schema = XmlSchema(interface)
schema.build_validation_schema()
return schema.validation_schema
开发者ID:plq,项目名称:spyne,代码行数:21,代码来源:xml.py
示例7: __init__
def __init__(self, interface=None,
_with_partnerlink=False):
'''Constructor.
:param app: The parent application.
:param import_base_namespaces: Include imports for base namespaces like
xsd, xsi, wsdl, etc.
:param _with_partnerlink: Include the partnerLink tag in the wsdl.
'''
XmlSchema.__init__(self, interface)
self._with_plink = _with_partnerlink
self.port_type_dict = {}
self.service_elt_dict = {}
self.root_elt = None
self.service_elt = None
self.__wsdl = None
self.validation_schema = None
开发者ID:66ru,项目名称:spyne,代码行数:21,代码来源:wsdl11.py
示例8: _build_xml_data_test_schema
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,代码行数:34,代码来源:test_xml_schema.py
示例9: get_validation_schema
def get_validation_schema(models, default_namespace=None):
'''Returns the validation schema object for the given models.
: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)
schema = XmlSchema(interface)
schema.build_validation_schema()
return schema.validation_schema
开发者ID:matafc,项目名称:spyne,代码行数:22,代码来源:xml.py
示例10: _test_xml_data
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,代码行数:36,代码来源:test_xml_schema.py
注:本文中的spyne.interface.xml_schema.XmlSchema类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论