本文整理汇总了Python中spyne.model.fault.Fault类的典型用法代码示例。如果您正苦于以下问题:Python Fault类的具体用法?Python Fault怎么用?Python Fault使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Fault类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
# TODO: self.transport.http.resp_code = HTTP_401
Fault.__init__(self,
faultcode='Client.AuthorizationError',
faultstring='You are not authorized to access this resource.'
)
示例2: __init__
def __init__(self, username):
# TODO: self.transport.http.resp_code = HTTP_401
Fault.__init__(
self,
faultcode='Client.LoginUnsupported',
faultstring='Login Unsupported for non free user %r' % username)
示例3: __init__
def __init__(self, obj, custom_msg='The value %r could not be validated.'):
s = repr(obj)
if len(s) > MAX_STRING_FIELD_LENGTH:
s = s[:MAX_STRING_FIELD_LENGTH] + "(...)"
Fault.__init__(self, 'Client.ValidationError', custom_msg % s)
示例4: __init__
def __init__(self):
Fault.__init__(self,
faultcode="Documented",
faultstring="A documented fault",
faultactor='http://faultactor.example.com',
detail=etree.Element('something')
)
示例5: serialize
def serialize(self, ctx, message):
assert message in (self.REQUEST, self.RESPONSE)
self.event_manager.fire_event('before_serialize', ctx)
if ctx.out_error is not None:
ctx.out_document = [Fault.to_dict(ctx.out_error.__class__,
ctx.out_error)]
else:
# get the result message
if message is self.REQUEST:
out_type = ctx.descriptor.in_message
elif message is self.RESPONSE:
out_type = ctx.descriptor.out_message
if out_type is None:
return
out_type_info = out_type._type_info
# instantiate the result message
out_instance = out_type()
# assign raw result to its wrapper, result_message
for i in range(len(out_type_info)):
attr_name = out_type_info.keys()[i]
setattr(out_instance, attr_name, ctx.out_object[i])
ctx.out_document = self._object_to_doc(out_type, out_instance),
self.event_manager.fire_event('after_serialize', ctx)
示例6: serialize
def serialize(self, ctx, message):
assert message in (self.REQUEST, self.RESPONSE)
self.event_manager.fire_event('before_serialize', ctx)
if ctx.out_error is not None:
ctx.out_document = [
[MessagePackRpc.MSGPACK_RESPONSE, 0,
Fault.to_dict(ctx.out_error.__class__, ctx.out_error)]
]
return
# get the result message
if message is self.REQUEST:
out_type = ctx.descriptor.in_message
msgtype = MessagePackRpc.MSGPACK_REQUEST
method_name_or_error = ctx.descriptor.operation_name
elif message is self.RESPONSE:
out_type = ctx.descriptor.out_message
msgtype = MessagePackRpc.MSGPACK_RESPONSE
method_name_or_error = None
else:
raise Exception("what?")
if out_type is None:
return
out_type_info = out_type._type_info
# instantiate the result message
out_instance = out_type()
# assign raw result to its wrapper, result_message
for i, (k, v) in enumerate(out_type_info.items()):
attr_name = k
out_instance._safe_set(attr_name, ctx.out_object[i], v)
# transform the results into a dict:
if out_type.Attributes.max_occurs > 1:
params = (self._to_dict_value(out_type, inst, set())
for inst in out_instance)
else:
params = self._to_dict_value(out_type, out_instance, set())
ctx.out_document = [[msgtype, 0, method_name_or_error, params]]
self.event_manager.fire_event('after_serialize', ctx)
示例7: serialize
def serialize(self, ctx, message):
assert message in (self.REQUEST, self.RESPONSE)
self.event_manager.fire_event('before_serialize', ctx)
if ctx.out_error is not None:
ctx.out_document = [MessagePackRpc.MSGPACK_RESPONSE, 0,
Fault.to_dict(ctx.out_error.__class__, ctx.out_error)]
else:
# get the result message
if message is self.REQUEST:
out_type = ctx.descriptor.in_message
elif message is self.RESPONSE:
out_type = ctx.descriptor.out_message
if out_type is None:
return
out_type_info = out_type._type_info
# instantiate the result message
out_instance = out_type()
# assign raw result to its wrapper, result_message
for i in range(len(out_type_info)):
attr_name = out_type_info.keys()[i]
setattr(out_instance, attr_name, ctx.out_object[i])
# transform the results into a dict:
if out_type.Attributes.max_occurs > 1:
ctx.out_document = [[MessagePackRpc.MSGPACK_RESPONSE, 0, None,
(self._to_value(out_type, inst)
for inst in out_instance)
]]
else:
ctx.out_document = [[MessagePackRpc.MSGPACK_RESPONSE, 0, None,
self._to_value(out_type, out_instance),
]]
self.event_manager.fire_event('after_serialize', ctx)
示例8: __init__
def __init__(self):
Fault.__init__(
self,
faultcode="ElbeAuthenticationFailed",
faultstring="Authentication Failed")
示例9: serialize
def serialize(self, ctx, message):
assert message in (self.REQUEST, self.RESPONSE)
self.event_manager.fire_event('before_serialize', ctx)
# construct the soap response, and serialize it
nsmap = self.app.interface.nsmap
ctx.out_document = {
"ver": self.version,
}
if ctx.out_error is not None:
ctx.out_document[self.FAULT] = Fault.to_dict(Fault, ctx.out_error)
else:
if message is self.REQUEST:
header_message_class = ctx.descriptor.in_header
body_message_class = ctx.descriptor.in_message
elif message is self.RESPONSE:
header_message_class = ctx.descriptor.out_header
body_message_class = ctx.descriptor.out_message
# assign raw result to its wrapper, result_message
out_type_info = body_message_class._type_info
out_object = body_message_class()
keys = iter(out_type_info)
values = iter(ctx.out_object)
while True:
try:
k = keys.next()
except StopIteration:
break
try:
v = values.next()
except StopIteration:
v = None
setattr(out_object, k, v)
ctx.out_document[self.BODY] = ctx.out_body_doc = \
self._object_to_doc(body_message_class, out_object)
# header
if ctx.out_header is not None and header_message_class is not None:
if isinstance(ctx.out_header, (list, tuple)):
out_headers = ctx.out_header
else:
out_headers = (ctx.out_header,)
ctx.out_header_doc = out_header_doc = []
for header_class, out_header in zip(header_message_class,
out_headers):
out_header_doc.append(self._object_to_doc(header_class,
out_header))
if len(out_header_doc) > 1:
ctx.out_document[self.HEAD] = out_header_doc
else:
ctx.out_document[self.HEAD] = out_header_doc[0]
self.event_manager.fire_event('after_serialize', ctx)
示例10: __init__
def __init__(self, faultstring):
Fault.__init__(self, 'Client.ValidationError',
'The value %r could not be validated.' % faultstring)
示例11: __init__
def __init__(self, fault_object,
fault_string="You do not have permission to access this resource"):
Fault.__init__(self, 'Client.InvalidCredentialsError', fault_string)
示例12: __init__
def __init__(self, faultstring):
Fault.__init__(self, 'Client.SchemaValidationError', faultstring)
示例13: __init__
def __init__(self):
Fault.__init__(self,
faultcode="Documented",
faultstring="A documented fault",
faultactor='http://faultactor.example.com',
)
示例14: __init__
def __init__(self, data=None):
Fault.__init__(self, "Client.MessagePackDecodeError", data)