Sypne 2.13.14b0 - абстрактный класс верхнего уровня не доступен - PullRequest
0 голосов
/ 16 апреля 2020

Абстрактный класс не выставляется в wsdl. В следующем примере B наследуется от A, а D наследуется от C. Однако в файле wsdl сообщается только о наследовании между A и B. В более общем смысле классы без аргументов не рассматриваются в файле wsdl. Я что-то упустил в определении класса или вы думаете, что в создании wsdl есть ошибка?

from spyne import Application, rpc, ServiceBase, Iterable, Integer, Unicode, ComplexModel
from spyne.protocol.soap import Soap11
from spyne.server.wsgi import WsgiApplication


class A(ComplexModel):
    __namespace__ = 'some_ns'

    _type_info = {
        '_a': Unicode(default="a"),
    }

    def __init__(self):
        super().__init__()
        self._a = "a"


class B(A):
    _type_info = {
        '_b': Unicode(default="a"),
    }

    def __init__(self):
        super().__init__()
        self._b = "b"


class C(ComplexModel):
    __namespace__ = 'some_ns'
    _type_info = {}

    def __init__(self):
        super().__init__()


class D(C):
    _type_info = {
        '_d': Unicode(default="d"),
    }

    def __init__(self):
        super().__init__()
        self._d = "d"


class HelloWorldService(ServiceBase):
    @rpc(A, B, C, D)
    def dummy_expose(ctx, a, b, c, d):
        """Docstrings for service methods appear as documentation in the wsdl.
        <b>dummy function to expose class definition A, B, C and D!</b>
        @param a expose class A
        @param b expose class B
        @param c expose class C
        @param d expose class D
        @return
        """
        return


application = Application([HelloWorldService], 'spyne.examples.poly.soap',
                          in_protocol=Soap11(validator='lxml'),
                          out_protocol=Soap11(polymorphic=True))

wsgi_application = WsgiApplication(application)


if __name__ == '__main__':
    import logging

    from wsgiref.simple_server import make_server

    logging.basicConfig(level=logging.DEBUG)
    logging.getLogger('spyne.protocol.xml').setLevel(logging.DEBUG)

    logging.info("listening to http://127.0.0.1:8000")
    logging.info("wsdl is at: http://localhost:8000/?wsdl")

    server = make_server('127.0.0.1', 8000, wsgi_application)
    server.serve_forever()

Вывод файла wsdl:

<xs:schema targetNamespace="some_ns" elementFormDefault="qualified">
  <xs:complexType name="C"/>
  <xs:complexType name="A">
    <xs:sequence>
      <xs:element name="_a" type="xs:string" minOccurs="0" default="a" nillable="true"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="D">
    <xs:sequence>
      <xs:element name="_d" type="xs:string" minOccurs="0" default="d" nillable="true"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="B">
    <xs:complexContent>
      <xs:extension base="s0:A">
        <xs:sequence>
          <xs:element name="_b" type="xs:string" minOccurs="0" default="a" nillable="true"/>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:element name="C" type="s0:C"/>
  <xs:element name="A" type="s0:A"/>
  <xs:element name="D" type="s0:D"/>
  <xs:element name="B" type="s0:B"/>
</xs:schema>
...