def fetch_listing_images(client, listing):
"""
Makes use of some built-in rets-python methods to get image URLs for a listing. Note:
this function (and get_listing_image()) were only necessary because rets-python failed
to return anything useful with its Record.get_object() method when the location
parameter was set to True.
"""
headers = {'Accept': '*/*'}
payload = {'Resource': 'Property', 'Type': 'Photo',
'ID': _build_entity_object_ids(
listing.resource_key), 'Location': 1}
encoding = 'utf-8'
try:
response = client.http._http_post(client.http._url_for('GetObject'),
headers=headers, payload=payload)
except (ProtocolError, ConnectionError, ConnectionResetError):
client.http.login()
response = client.http._http_post(client.http._url_for('GetObject'),
headers=headers, payload=payload)
multipart = MultipartDecoder.from_response(response, encoding)
return multipart.parts
评论列表
文章目录