loris-imageserver / loris

Loris IIIF Image Server
Other
208 stars 87 forks source link

Proposal: Resolvers to return partial ImageInfo object #299

Open azaroth42 opened 7 years ago

azaroth42 commented 7 years ago

resolver.resolve() is called in three places:

In each case, the next functional step is to pass the results through to create the image info object before any further processing happens. (There's some debugging and a sanity check that play no significant role in the first instance)

I propose that the ImageInfo object could be constructed by the resolver, and filled out with the source filepath and format, plus the potential for other properties to cache the authorization rules for example. Then the object would be passed to _get_info or from_image_file to build out the rest of the information. This would then allow extra information to be added in custom resolvers and passed through to authorizers or transformers, without the need to touch the core webapp workflow.

Thoughts?

jpstroop commented 7 years ago

I don't love the idea of passing a class to a some other class to have its properties updated--but there is definitely some of that going on already. Want to mock it up?

azaroth42 commented 7 years ago

The challenge even without Authentication is how to get access to a sidecar file that stores attribution, logo, license and other non-automated services. The efficient place to grab that information is in the resolver, as it's already looking at files/representations. It's either carry it around as variables like the fp and format, have a different cache that the resolver creates in the global space somehow, or put it directly where it needs to be ... which is in the info.json.

Working on an implementation to demonstrate.

azaroth42 commented 7 years ago

Implementation done and seems to work :)

The major change is that now the only place that calls resolve() is: https://github.com/azaroth42/loris/blob/auth/loris/webapp.py#L488

It is then decorated with the now non static call to from_image_file at L500 All other references that would have used resolver directly in webapp, instead call _get_info()

(Please ignore all the other auth changes in the same branch for the purposes of this issue)