这是一些 Spyne/SOAP 代码,我在其中返回一两个字符串。有没有办法避免必须将 string2 设置为 None 以表明它不存在?
class TestResult(ComplexModel):
"""
"""
string1 = Unicode
string2 = Unicode(min_occurs=0, max_occurs=1)
def __init__(self):
# Say hello
self.string1 = "Hello World"
# Either of the following works
#
# self.string2 = "...from Paul"
# self.string2 = None
#
# But omitting them doesn't.
class Test(ServiceBase):
"""
"""
@srpc(Unicode, _returns=TestResult)
def Test(Query):
"""
"""
response = TestResult()
return response