I have been trying to modify the Reply class of suds.transport.
I tried with the following approach:
import suds.transport
old_reply = suds.transport.Reply
class Reply2:
"""
A transport reply
@ivar code: The http code returned.
@type code: int
@ivar message: The message to be sent in a POST request.
@type message: str
@ivar headers: The http headers to be used for the request.
@type headers: dict
"""
def __init__(self, code, headers, message):
"""
@param code: The http code returned.
@type code: int
@param headers: The http returned headers.
@type headers: dict
@param message: The (optional) reply message received.
@type message: str
"""
print 'hello, i patched the class'
self.code = code
self.headers = headers
self.message = message
def __str__(self):
s = []
s.append('CODE: %s' % self.code)
s.append('HEADERS: %s' % self.headers)
s.append('MESSAGE:')
s.append(self.message)
return '\n'.join(s)
suds.transport.Reply = Reply2
When executing a client
request (as you would normally with Suds), the default Reply is used instead of the patched one.
What could be a reason that this approach is failing?
Note: it seems that patching the __init__
separately does give better results. But I need to modify more behaviour in the class.
In the end, I'm trying to override Reply to get incoming attachments, like asked on SO and the solution here