2

このような装飾されたクラスを継承しようとしています

class SOAPCategoy(ComplexModel):
    id = Integer
    CategoyName = Unicode

class SOAPServiceBase(ServiceBase):
   @rpc(Integer, _returns=SOAPSeller)
   def Item(self, pId):
      ....
      return SOAPCategory()

class SOAPCategoryService(SOAPServiceBase):
   pass

.
.
.
wsgi_app = wsgi_soap_application([SOAPCategoryService], 'test.soap')

次に、エラーがスローされます。

File "...spyne/interface/xml_schema/_base.py", line 186, in build_validation_schema
f = open('%s/%s.xsd' % (tmp_dir_name, pref_tns), 'r')
IOError: [Errno 2] No such file or directory: '/tmp/spyne9y_uw9/tns.xsd'

_base.py ソースコードの一部

def build_validation_schema(self):
    """Build application schema specifically for xml validation purposes."""

    self.build_schema_nodes(with_schema_location=True)

    pref_tns = self.interface.get_namespace_prefix(self.interface.tns)
    tmp_dir_name = tempfile.mkdtemp(prefix='spyne')
    logger.debug("generating schema for targetNamespace=%r, prefix: "
              "%r in dir %r" % (self.interface.tns, pref_tns, tmp_dir_name))

    # serialize nodes to files
    for k, v in self.schema_dict.items():
        file_name = '%s/%s.xsd' % (tmp_dir_name, k)
        f = open(file_name, 'wb')
        etree.ElementTree(v).write(f, pretty_print=True)
        f.close()
        logger.debug("writing %r for ns %s" % (file_name,
                                                   self.interface.nsmap[k]))

    f = open('%s/%s.xsd' % (tmp_dir_name, pref_tns), 'r')
4

2 に答える 2

1

Spyne は、子に対して継承を使用できないServiceBaseように設計されています。コンポジションを使用する必要があります。

class SOAPServiceBase(ServiceBase):
   @rpc(Integer, _returns=SOAPSeller)
   def Item(self, pId):
      # ....
      return SOAPCategory()

class SOAPCategoryService(ServiceBase):
   # ...

wsgi_app = wsgi_soap_application([SOAPServiceBase, SOAPCategoryService], 'test.soap')

異なるエンドポイントから同じサービス パックをエクスポートする必要がある場合は、次のようにする必要があります。

def TSoapServiceBase():
    class SOAPServiceBase(ServiceBase):
       @rpc(Integer, _returns=SOAPSeller)
       def Item(self, pId):
          # ....
          return SOAPCategory()

    return SOAPServiceBase

some_app = wsgi_soap_application([TSoapServiceBase()], 'test.soap')
some_other_app = wsgi_soap_application([TSoapServiceBase()], 'test.soap')
# etc...
于 2013-09-22T21:58:27.920 に答える