Overview
In GeoNode we're getting more and more resources that need specific handling based on several traits (the underlying model, the subtype, the source, etc.). The current approach where the resource logic is coupled to the underlying Django model is falling short.
We want to delegate more to the ResourceManager through a new ResourceHandler concept, similar to the handlers already implemented inside the importer and for assets.
Dispatching actions and requests to the ResourceHandler will be implemented using the same approach as the importer: an ordered list of ResourceHandlers will be iterated by the ResourceManager to elect the handler for the current resource. The first wins, so handlers must be ordered by decreasing specificity.
For example, a handler for a Vector Datasetmust come first of the handler for a generic Dataset.
The first use case for ResourceHandlers will be delegating the calculation of download URLs and processing the download response.
At the moment we have the following:
the DownloadArrayLinkField serializer obtains the download_url either from the Document.document_url property, or the DatasetDownloadHandler.download_url property. Problems:
this logic is not a concern of the field serializer
we have if/else logic, which is bad
for 3dtiles we need additional if/else cases
Each download URL calls a specific view (Document, Dataset, etc.).
With ResourceHandlers
DownloadArrayLinkField will ask the ResourceManager to provide the URL. This in turns will elect the right handler and dispatch the request to it. The ResourceHanlder can delegate again to a DownloadHandler (this is required at least for datasets, so we can maintain the current option to implement custom Dataset download handlers)
The URLs should call a base view that will let the ResourceManager again dispatch the response processing to the specific Resource handlers
Overview In GeoNode we're getting more and more resources that need specific handling based on several traits (the underlying model, the subtype, the source, etc.). The current approach where the resource logic is coupled to the underlying Django model is falling short.
We want to delegate more to the
ResourceManager
through a newResourceHandler
concept, similar to the handlers already implemented inside the importer and for assets.Dispatching actions and requests to the ResourceHandler will be implemented using the same approach as the importer: an ordered list of ResourceHandlers will be iterated by the ResourceManager to elect the handler for the current resource. The first wins, so handlers must be ordered by decreasing specificity. For example, a handler for a
Vector Dataset
must come first of the handler for a genericDataset
.The first use case for ResourceHandlers will be delegating the calculation of download URLs and processing the download response. At the moment we have the following:
DownloadArrayLinkField
serializer obtains thedownload_url
either from theDocument.document_url
property, or theDatasetDownloadHandler.download_url
property. Problems:Document
,Dataset
, etc.).With ResourceHandlers
DownloadArrayLinkField
will ask theResourceManager
to provide the URL. This in turns will elect the right handler and dispatch the request to it. TheResourceHanlder
can delegate again to aDownloadHandler
(this is required at least for datasets, so we can maintain the current option to implement customDataset
download handlers)ResourceManager
again dispatch the response processing to the specific Resource handlers