def _get_response(self, args=[], kwargs={}):
""" Get response from ``args`` or ``kwargs``. """
# If you're decorating a function without response objects as arguments
# or invalid ones, you can set this attribute that has precedence.
if hasattr(self, 'response_for_pagination_mixin'):
return self.response_for_pagination_mixin
total_args = list(args) + list(kwargs.values())
response_objs = [obj for obj in total_args if isinstance(obj, Response)]
n_response_objs = len(response_objs)
if n_response_objs == 0:
raise ValueError('No response could be extracted.')
if n_response_objs == 1:
return response_objs[0]
elif n_response_objs > 1:
logging.warning('[-] Detected more than one response. Using the first one.')
return response_objs[0]
评论列表
文章目录