Skip to content

Commit

Permalink
Avoid assuming that access_url exists always
Browse files Browse the repository at this point in the history
DatalinkResultsMixin was assuming that the records created by any
subclass would have the `access_url` attribute. This is not true for SSA
(whether it should do is a separate question). This replaces that
assumption with a check for existence first, and then if that fails,
fall back to getdatalink on the record.
  • Loading branch information
aragilar committed Jul 1, 2024
1 parent 29383f0 commit 298797e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pyvo/dal/adhoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,14 @@ def iter_datalinks(self):
processed_ids.append(id1)
remaining_ids.remove(id1)
yield current_batch.clone_byid(id1)
elif row.access_format == DATALINK_MIME_TYPE:
elif getattr(row, 'access_format', None) == DATALINK_MIME_TYPE:
yield DatalinkResults.from_result_url(row.getdataurl())
else:
yield None
# Fall back to row-specific handling
try:
yield row.getdatalink()
except AttributeError:
yield None


class DatalinkRecordMixin:
Expand Down

0 comments on commit 298797e

Please sign in to comment.