|
16 | 16 |
|
17 | 17 |
|
18 | 18 | class GeneralSudsPlugin(MessagePlugin):
|
| 19 | + """ |
| 20 | + General Suds Plugin: Adds logging request and response functionality |
| 21 | + and prunes empty WSDL objects before sending. |
| 22 | + """ |
| 23 | + |
19 | 24 | def __init__(self, **kwargs):
|
| 25 | + """Initializes the request and response loggers.""" |
20 | 26 | self.request_logger = logging.getLogger('fedex.request')
|
21 | 27 | self.response_logger = logging.getLogger('fedex.response')
|
22 | 28 | self.kwargs = kwargs
|
23 | 29 |
|
24 | 30 | def marshalled(self, context):
|
25 |
| - # Removes the WSDL objects that do not have a value before sending. |
| 31 | + """Removes the WSDL objects that do not have a value before sending.""" |
26 | 32 | context.envelope = context.envelope.prune()
|
27 | 33 |
|
28 | 34 | def sending(self, context):
|
| 35 | + """Logs the sent request.""" |
29 | 36 | self.request_logger.info("FedEx Request {}".format(context.envelope))
|
30 | 37 |
|
31 | 38 | def received(self, context):
|
| 39 | + """Logs the received response.""" |
32 | 40 | self.response_logger.info("FedEx Response {}".format(context.reply))
|
33 | 41 |
|
34 | 42 |
|
@@ -263,9 +271,9 @@ def _check_response_for_request_warnings(self):
|
263 | 271 | on postal code in a Rate Service request.
|
264 | 272 | """
|
265 | 273 |
|
266 |
| - if self.response.HighestSeverity == "NOTE": |
| 274 | + if self.response.HighestSeverity in ("NOTE", "WARNING"): |
267 | 275 | for notification in self.response.Notifications:
|
268 |
| - if notification.Severity == "NOTE": |
| 276 | + if notification.Severity in ("NOTE", "WARNING"): |
269 | 277 | self.logger.warning(FedexFailure(notification.Code,
|
270 | 278 | notification.Message))
|
271 | 279 |
|
@@ -326,6 +334,6 @@ def send_request(self, send_function=None):
|
326 | 334 | # This method can be overridden by a method on the child class object.
|
327 | 335 | self._check_response_for_request_warnings()
|
328 | 336 |
|
329 |
| - # Debug output. |
| 337 | + # Debug output. (See Request and Response output) |
330 | 338 | self.logger.debug("== FEDEX QUERY RESULT ==")
|
331 | 339 | self.logger.debug(self.response)
|
0 commit comments