|
|
|
@ -2,6 +2,25 @@ from spyne.service import Service, ServiceMeta
|
|
|
|
|
from spyne import String, Integer, Array, rpc
|
|
|
|
|
from func import WsdlMeta
|
|
|
|
|
from api_types import ReturnedMessage, ViewInfo, ViewParams
|
|
|
|
|
from spyne.protocol._outbase import OutProtocolBase
|
|
|
|
|
from api_types import LazyString
|
|
|
|
|
|
|
|
|
|
#monkey patch:
|
|
|
|
|
#we add a check for a lazy string
|
|
|
|
|
def to_unicode(self, cls, value, *args, **kwargs):
|
|
|
|
|
if value is None:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
if isinstance(value, LazyString):
|
|
|
|
|
value = str(value)
|
|
|
|
|
|
|
|
|
|
handler = self._to_unicode_handlers[cls]
|
|
|
|
|
retval = handler(cls, value, *args, **kwargs)
|
|
|
|
|
|
|
|
|
|
return retval
|
|
|
|
|
|
|
|
|
|
OutProtocolBase.to_unicode = to_unicode
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ServiceMetaAdapter(ServiceMeta):
|
|
|
|
|
#ref to the created class
|
|
|
|
@ -10,15 +29,15 @@ class ServiceMetaAdapter(ServiceMeta):
|
|
|
|
|
class CoreInnerWsdl(ServiceMeta, WsdlMeta):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
# Nevermind, following is deprecated:
|
|
|
|
|
|
|
|
|
|
#the idea is to decorate methods that need rpc with this
|
|
|
|
|
#and then find them in make_service and wrap them in funcs without self ref
|
|
|
|
|
def rpc_a():
|
|
|
|
|
def func(f):
|
|
|
|
|
f.wrap_rpc = True
|
|
|
|
|
return f
|
|
|
|
|
return func
|
|
|
|
|
|
|
|
|
|
# def rpc_a():
|
|
|
|
|
# def func(f):
|
|
|
|
|
# f.wrap_rpc = True
|
|
|
|
|
# return f
|
|
|
|
|
# return func
|
|
|
|
|
|
|
|
|
|
#wraps a func in rpc decorator
|
|
|
|
|
#this is needed because Spyne service does not allow self ref in function calls
|
|
|
|
@ -41,26 +60,8 @@ def make_rpc_func_caller(func_to_call):
|
|
|
|
|
info_class = func_to_call.info_class
|
|
|
|
|
return rpc(Integer, info_class, _returns=Array(ReturnedMessage))(_function)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def make_service_from_wsdl_classes(class_list, service_name, ClService):
|
|
|
|
|
pass
|
|
|
|
|
# functions_to_add = {}
|
|
|
|
|
# for klass in class_list:
|
|
|
|
|
# for meth in klass.__dict__:
|
|
|
|
|
# # print(meth)
|
|
|
|
|
# # print(getattr(klass, meth))
|
|
|
|
|
# if not meth.startswith("__") and not meth == "methods" and not meth.endswith("_vars"):
|
|
|
|
|
# # print(meth)
|
|
|
|
|
# # print(getattr(klass, meth))
|
|
|
|
|
# if meth.endswith("_view"):
|
|
|
|
|
# functions_to_add[meth] = make_rpc_func_view(getattr(klass, meth), ClService)
|
|
|
|
|
# else:
|
|
|
|
|
# functions_to_add[meth] = make_rpc_func_caller(getattr(klass, meth), ClService)
|
|
|
|
|
|
|
|
|
|
# return ServiceMeta(service_name, tuple([Service]), functions_to_add)
|
|
|
|
|
|
|
|
|
|
def make_service(basic_class, wsdl_core_class_list, outer_wsdl_class_list, service_name):
|
|
|
|
|
#for Core, rpc methods only present in basic_class, we need the others to have a single structure
|
|
|
|
|
#for Core, rpc methods only present in basic_class, we need others just to have a mono class
|
|
|
|
|
#for outer wsdl classes, we have to add stateless wrap methods on our own
|
|
|
|
|
|
|
|
|
|
saved_pub_methods = basic_class.public_methods
|
|
|
|
|