从 spyne 响应中删除标签

Remove tag from spyne response

我正在使用 spyne 创建一个网络服务,因此我的代码如下所示:

class bndbox(ComplexModel):
    xmin = Integer
    ymin = Integer
    xmax = Integer  
    ymax = Integer
    score = Integer

class object(ComplexModel):
    name = String
    objects = Array(bndbox)

class SKUObjectsDetected(ComplexModel): 
    annotation = Array(object)


def add_SKUObject(skuobject):
    #global sku_object_database
    sku_object_database.append(skuobject)

class ObjectDetectionService(Service):
    @srpc(Unicode, _returns=SKUObjectsDetected)
    def find_objects(encoded_string):
        .
        .
        .
        return SKUObjectsDetected(annotation=sku_object_database)

它工作正常。实际上响应如下:

<soap11env:Envelope xmlns:tns="object_detection_service" xmlns:soap11env="http://schemas.xmlsoap.org/soap/envelope/">
  <soap11env:Body>
    <tns:find_objectsResponse>
      <tns:annotation>
        <tns:object>
          <tns:objects>
            <tns:bndbox>
              <tns:xmin>151</tns:xmin>
              <tns:ymin>183</tns:ymin>
              <tns:score>34</tns:score>
              <tns:xmax>169</tns:xmax>
              <tns:ymax>272</tns:ymax>
            </tns:bndbox>
            <tns:bndbox>
              <tns:xmin>190</tns:xmin>
              <tns:ymin>12</tns:ymin>
              <tns:score>32</tns:score>
              <tns:xmax>300</tns:xmax>
              <tns:ymax>92</tns:ymax>
            </tns:bndbox>
            <tns:bndbox>
              <tns:xmin>284</tns:xmin>
              <tns:ymin>5</tns:ymin>
              <tns:score>28</tns:score>
              <tns:xmax>300</tns:xmax>
              <tns:ymax>65</tns:ymax>
            </tns:bndbox>
          </tns:objects>
          <tns:name>Car</tns:name>
        </tns:object>        
      </tns:annotation>
    </tns:find_objectsResponse>
  </soap11env:Body>
</soap11env:Envelope>

但是,是否可以删除 <tns:objects> 标签?其他标签都很好,我只需要删除它。对应object class.

中的objects数组

谢谢。

而不是

Array(bndbox)

使用

bndbox.customize(max_occurs='unbounded')