我正试图让ladon工作,但是,我似乎无法正确定义服务。
具体来说,即使是最小的测试用例,它也在抛出
Traceback (most recent call last):
File "C:\Python33\lib\site-packages\ladon\server\wsgi_application.py", line 332, in __call__
self.import_services(self.service_list)
File "C:\Python33\lib\site-packages\ladon\server\wsgi_application.py", line 288, in import_services
__import__(service)
File "D:\Workspaces\Python\SOAPManager.py", line 20, in <module>
@ladonize(PORTABLE_STRING, PORTABLE_STRING, rtype=PORTABLE_STRING)
File "C:\Python33\lib\site-packages\ladon\ladonizer\decorator.py", line 118, in decorator
injector.__doc__ = ladon_method_info._doc
AttributeError: 'NoneType' object has no attribute '_doc'
我的Run.py包含:
from ladon.server.wsgi import LadonWSGIApplication
from os.path import abspath, dirname
from wsgiref.simple_server import make_server
application = LadonWSGIApplication(
['SOAPManager'],
[dirname(abspath(__file__))],
catalog_name='API',
catalog_desc='API Description')
httpd = make_server('0.0.0.0', 8004, application)
print("Listening on port 8004...")
# Respond to requests until process is killed
httpd.serve_forever()
SOAPManager.py中的最小测试用例:
from ladon.ladonizer import ladonize
from ladon.types.ladontype import LadonType
from ladon.compat import PORTABLE_STRING
@ladonize(PORTABLE_STRING, PORTABLE_STRING, rtype=PORTABLE_STRING)
def Authenticate(Username, Password):
return "Test"
从ladonize
装饰器中引发错误。在尝试构建服务定义时似乎正在发生。具体来说,在小伙伴decorator
调用collection.add_service_method
,它返回None
而不是方法。我认为没有通过行号检查。
firstlineno = f.__code__.co_firstlineno
# get an ast-analyzed object of the source file
sinfo = self.source_info(src_fname)
...
for clsname,v in sinfo.items():
if firstlineno>v[0] and firstlineno<=v[1]:
由于某种原因,检查失败,因此方法默认返回None
。