本文整理汇总了Python中spyne.model.complex.ComplexModel.alias方法的典型用法代码示例。如果您正苦于以下问题:Python ComplexModel.alias方法的具体用法?Python ComplexModel.alias怎么用?Python ComplexModel.alias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyne.model.complex.ComplexModel
的用法示例。
在下文中一共展示了ComplexModel.alias方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _produce_output_message
# 需要导入模块: from spyne.model.complex import ComplexModel [as 别名]
# 或者: from spyne.model.complex.ComplexModel import alias [as 别名]
def _produce_output_message(func_name, kparams):
"""Generate an output message for "rpc"-style API methods.
This message is a wrapper to the declared return type.
"""
_returns = kparams.get('_returns')
_body_style = _validate_body_style(kparams)
_out_message_name = kparams.get('_out_message', '%s%s' %
(func_name, RESPONSE_SUFFIX))
out_params = TypeInfo()
if _returns and _body_style == 'wrapped':
if isinstance(_returns, (list, tuple)):
default_names = ['%s%s%d' % (func_name, RESULT_SUFFIX, i) for i in
range(len(_returns))]
_out_variable_names = kparams.get('_out_variable_names',
default_names)
assert (len(_returns) == len(_out_variable_names))
var_pair = zip(_out_variable_names, _returns)
out_params = TypeInfo(var_pair)
else:
_out_variable_name = kparams.get('_out_variable_name',
'%s%s' % (func_name, RESULT_SUFFIX))
out_params[_out_variable_name] = _returns
ns = DEFAULT_NS
if _out_message_name.startswith("{"):
ns = _out_message_name[1:].partition("}")[0]
if _body_style == 'bare' and _returns is not None:
message = ComplexModel.alias(_out_message_name, ns, _returns)
else:
message = ComplexModel.produce(type_name=_out_message_name,
namespace=ns,
members=out_params)
message.Attributes._wrapper = True
message.__namespace__ = ns # FIXME: is this necessary?
return message
示例2: Exception
# 需要导入模块: from spyne.model.complex import ComplexModel [as 别名]
# 或者: from spyne.model.complex.ComplexModel import alias [as 别名]
raise Exception("The parameter numbers of the %r function and its "
"decorator mismatch." % f.func_name)
ns = DEFAULT_NS
if _in_message_name.startswith("{"):
ns = _in_message_name[1:].partition("}")[0]
if _body_style == 'bare':
if len(in_params) > 1:
raise Exception("body_style='bare' can handle at most one function "
"argument.")
in_param = None
if len(in_params) == 1:
in_param, = in_params.values()
message = ComplexModel.alias(_in_message_name, ns, in_param)
else:
message = ComplexModel.produce(type_name=_in_message_name, namespace=ns,
members=in_params)
message.__namespace__ = ns
return message
def _validate_body_style(kparams):
_body_style = kparams.get('_body_style')
_soap_body_style = kparams.get('_soap_body_style')
if _body_style is None:
_body_style = 'wrapped'
elif not (_body_style in ('wrapped', 'bare')):