gpt4 book ai didi

python - 如何用Spyne描述元素属性

转载 作者:行者123 更新时间:2023-11-30 21:50:28 24 4
gpt4 key购买 nike

我同意Spyne's hello world examples ,但是当涉及到更复杂的事情时,我面临着缺乏文档和高级示例的问题。就我而言,我有一个接受这样的正文的服务方法

<OTA_HotelAvailRQ xmlns="http://www.opentravel.org/OTA/2003/05" Version="1.0" TimeStamp="2005-08-01T09:30:47+02:00" EchoToken="fb57388d" AvailRatesOnly="true">
<AvailRequestSegments>
<AvailRequestSegment AvailReqType="Room">
<HotelSearchCriteria>
<Criterion>
<HotelRef HotelCode="HOTEL1"/>
</Criterion>
</HotelSearchCriteria>
</AvailRequestSegment>
</AvailRequestSegments>
</OTA_HotelAvailRQ>

您能帮助我实现接受此类请求的服务吗?

最佳答案

从我的头顶上下来:

class HotelReference(ComplexModel):
__namespace__ = 'http://www.opentravel.org/OTA/2003/05'

HotelCode = XmlAttribute(Unicode)

class Criterion(ComplexModel):
__namespace__ = 'http://www.opentravel.org/OTA/2003/05'

HotelRef = HotelReference

class AvailRequestSegment(ComplexModel):
__namespace__ = 'http://www.opentravel.org/OTA/2003/05'

AvailReqType = XmlAttribute(Unicode(values=["Room", "House", "Condo", "Castle"]))
HotelSearchCriteria = Criterion.customize(max_occurs='unbounded')

class HotelAvailRQ(ComplexModel):
__namespace__ = 'http://www.opentravel.org/OTA/2003/05'

Version = XmlAttribute(Unicode)
TimeStamp = XmlAttribute(DateTime)
EchoToken = XmlAttribute(ByteArray)
AvailRatesOnly XmlAttribute(Boolean)

AvailRequestSegments = Array(AvailRequestSegment)

关于python - 如何用Spyne描述元素属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19514045/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com