フラスコエンタープライズを使用したかったのですが、ドキュメントやいくつかの例を見つけることができませんでした. プリミティブ型を返したい場合は簡単ですが、クラスを返したい場合はそれができません。
from soaplib.core.model.clazz import ClassModelBase
from flaskext.enterprise import Enterprise
from flask import Flask, render_template
#config Flask Enterprise
enterprise = Enterprise(app)
String = enterprise._sp.String
Integer = enterprise._sp.Integer
Boolean = enterprise._sp.Boolean
Array = enterprise._scls.Array
class T(ClassModelBase):
date=""
time=""
class Service(enterprise.SOAPService):
"""Soap Service Class
Attributes:
__soap_target_namespace__ : namespace for soap service
__soap_server_address__ : address of soap service
"""
__soap_target_namespace__ = 'TNS'
__soap_server_address__ = '/soap'
@enterprise.soap(String, _returns=Integer)
def reg(self, strIdent):
"""
Args:
strIdent : string
Returns:
retrurn an int
"""
return 1
@enterprise.soap(String,_returns=Array(T))
def getT(self, strIdent):
"""
Args:
strIdent : string
Returns:
return an array of classes
"""
arr=[]
arr.append(T(date="12.09.", time="17:00"))
arr.append(T(date="13.09.", time="18:00"))
return arr
サービス reg は正常に動作しますが、サービス getT にエラーがあります
[Tue Aug 25 17:35:01 2015] [error] [client #######] mod_wsgi (pid=#####): Target WSGI script '/###/#####.wsgi' cannot be loaded as Python module.
[Tue Aug 25 17:35:01 2015] [error] [client #######] mod_wsgi (pid=#####): Exception occurred processing WSGI script '/###/#####.wsgi'.
[Tue Aug 25 17:35:01 2015] [error] [client #######] Traceback (most recent call last):
[Tue Aug 25 17:35:01 2015] [error] [client #######] File "/###/#####.wsgi", line 5, in <module>
[Tue Aug 25 17:35:01 2015] [error] [client #######] from t.app import app as application
[Tue Aug 25 17:35:01 2015] [error] [client #######] File "/###/#####.wsgi", line 28, in <module>
[Tue Aug 25 17:35:01 2015] [error] [client #######] class Service(enterprise.SOAPService):
[Tue Aug 25 17:35:01 2015] [error] [client #######] File "/usr/local/lib/python2.7/dist-packages/flaskext/enterprise.py", line 104, in __new__
[Tue Aug 25 17:35:01 2015] [error] [client #######] self.controller.register_soap_service(rv)
[Tue Aug 25 17:35:01 2015] [error] [client #######] File "/usr/local/lib/python2.7/dist-packages/flaskext/enterprise.py", line 45, in register_soap_service
[Tue Aug 25 17:35:01 2015] [error] [client #######] soap_app = Application([service], service.__soap_target_namespace__)
[Tue Aug 25 17:35:01 2015] [error] [client #######] File "/usr/local/lib/python2.7/dist-packages/soaplib/core/_base.py", line 317, in __init__
[Tue Aug 25 17:35:01 2015] [error] [client #######] self.schema = self.build_schema()
[Tue Aug 25 17:35:01 2015] [error] [client #######] File "/usr/local/lib/python2.7/dist-packages/soaplib/core/_base.py", line 686, in build_schema
[Tue Aug 25 17:35:01 2015] [error] [client #######] inst = self.get_service(s)
[Tue Aug 25 17:35:01 2015] [error] [client #######] File "/usr/local/lib/python2.7/dist-packages/soaplib/core/_base.py", line 727, in get_service
[Tue Aug 25 17:35:01 2015] [error] [client #######] return service(http_req_env)
[Tue Aug 25 17:35:01 2015] [error] [client #######] File "/usr/local/lib/python2.7/dist-packages/soaplib/core/service.py", line 296, in __init__
[Tue Aug 25 17:35:01 2015] [error] [client #######] _public_methods_cache[cls] = self.build_public_methods()
[Tue Aug 25 17:35:01 2015] [error] [client #######] File "/usr/local/lib/python2.7/dist-packages/soaplib/core/service.py", line 384, in build_public_methods
[Tue Aug 25 17:35:01 2015] [error] [client #######] descriptor = func(_method_descriptor=True, clazz=self.__class__)
[Tue Aug 25 17:35:01 2015] [error] [client #######] File "/usr/local/lib/python2.7/dist-packages/soaplib/core/service.py", line 176, in explain_method
[Tue Aug 25 17:35:01 2015] [error] [client #######] kparams
[Tue Aug 25 17:35:01 2015] [error] [client #######] File "/usr/local/lib/python2.7/dist-packages/soaplib/core/service.py", line 90, in _produce_rpc_output_message
[Tue Aug 25 17:35:01 2015] [error] [client #######] message.resolve_namespace(message, ns)
[Tue Aug 25 17:35:01 2015] [error] [client #######] File "/usr/local/lib/python2.7/dist-packages/soaplib/core/model/clazz.py", line 266, in resolve_namespace
[Tue Aug 25 17:35:01 2015] [error] [client #######] v.resolve_namespace(v, default_ns)
[Tue Aug 25 17:35:01 2015] [error] [client #######] File "/usr/local/lib/python2.7/dist-packages/soaplib/core/model/clazz.py", line 389, in resolve_namespace
[Tue Aug 25 17:35:01 2015] [error] [client #######] serializer.resolve_namespace(serializer, default_ns)
[Tue Aug 25 17:35:01 2015] [error] [client #######] File "/usr/local/lib/python2.7/dist-packages/soaplib/core/model/clazz.py", line 260, in resolve_namespace
[Tue Aug 25 17:35:01 2015] [error] [client #######] for k, v in cls._type_info.items():
[Tue Aug 25 17:35:01 2015] [error] [client #######] AttributeError: type object 'Tips' has no attribute '_type_info'