archivesspace-labs / ArchivesSnake

A client library for working with the ArchivesSpace API
https://archivesspace-labs.github.io/ArchivesSnake/
Other
78 stars 13 forks source link

Search route, maybe other on JSONModelObject throws AttributeError #14

Closed pobocks closed 6 years ago

pobocks commented 6 years ago

Currently, calling methods on JSONModelObjects that require arguments other than all_ids to return successfully causes an AttributeError to be raised.

Triggering code:

x.repositories(2).search # should be JSONRelation, throws AttributeError

Cause: Currently, getattribute on jsonmodels does a call with all_ids, eagerly at time of object creation. This is fine (if extra work) for index routes. It fails dramatically for search.

Honestly, I'm not sure what the Right Thing is to do. There isn't a generic way to handle this "properly" (i.e. fails in getattribute with an error saying that there's no route, because HEAD ALSO errors out for search. I'm hesitant to just say "if you call something that's not on the object, you get a relation and then the relation fails if it wasn't real" because that moves the place failures happen potentially several steps down the road; you don't find out it's bad until you try to iterate through the relation.