ckan / ckan

CKAN is an open-source DMS (data management system) for powering data hubs and data portals. CKAN makes it easy to publish, share and use data. It powers catalog.data.gov, open.canada.ca/data, data.humdata.org among many other sites.

Home Page:https://ckan.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Catch AttributeErrors in license retrieval

thorge opened this issue · comments

The following code segment may also result in an AttributeError:

package[u'isopen'] = model.Package.get_license_register()[license_id
].isopen()

If, for some reason, the license object returned by model.Package.get_license_register()[license_id] does not have an isopen attribute or method, trying to call isopen() would result in an AttributeError, as well if model.Package.get_license_register()[license_id] evaluates to None. Currently, only KeyErrors are being caught.

It is advisable to include AttributeError in the except handle of the try block:

except (KeyError, AttributeError):
    package[u'isopen'] = False

@amercader @thorge , I am interested to work on this issue. I will submit a PR.