我有一个工作的 web.py 应用程序和一个工作的 Spyne 应用程序。我想在匹配某个 url 时向 spyne 应用程序发出 web.py 路由请求。
我按照 web.py 文档尝试了一个包装器,但没有运气。
在 myspyne.py 中:
import logging
logging.basicConfig(level=logging.DEBUG)
from spyne.application import Application
from spyne.decorator import srpc
from spyne.service import ServiceBase
from spyne.model.primitive import Integer
from spyne.model.primitive import Unicode
from spyne.model.complex import Iterable
from spyne.protocol.soap import Soap11
class HelloWorldService(ServiceBase):
@srpc(Unicode, Integer, _returns=Iterable(Unicode))
def say_hello(name, times):
for i in range(times):
yield 'Hello, %s' % name
application = Application([HelloWorldService],
tns='my.custom.ns',
in_protocol=Soap11(validator='lxml'),
out_protocol=Soap11())
在 myweb.py 中:
urls = (
'/', 'index',
'/myspyne/(.*)', myspyne.application, # this does not work
)
class index:
def GET(self):
return "hello"
app = web.application(urls, globals(), autoreload=False)
application = app.wsgifunc()
if __name__ == '__main__':
app.run()