我是第一次使用SPYNE,我对如何使用我的 ComplexModel 做出响应感到有些困惑。
#service.py
class Status(ComplexModel):
statusCode = Integer
statusMsg = String
class ResponseData(ComplexModel):
status = Array(Status)
version = Integer
class SoapService(ServiceBase):
@rpc(String, _returns=ResponseData)
def doSomething(ctx, name):
# ...
# do something to get a django-model-object
obj_data = Servers.objects.get(host=name)
# put vars from the django-model-object into 'ResponseData' and nested 'Status'
# e.g. statusCode = 1, statusMsg = 'online', version = 1
""" experimental - status is not returned - version is 1:
obj_status = Status()
obj_status.statusCode = 1
obj_status.statusMsg = 'online'
retval = ResponseData()
retval.status = obj_status
retval.version = 1
"""
return retval