Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the ResourceHandler concept #12456

Open
giohappy opened this issue Jul 30, 2024 · 0 comments · May be fixed by #12469
Open

Implement the ResourceHandler concept #12456

giohappy opened this issue Jul 30, 2024 · 0 comments · May be fixed by #12469
Assignees
Milestone

Comments

@giohappy
Copy link
Contributor

giohappy commented Jul 30, 2024

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 Dataset must 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:
    1. this logic is not a concern of the field serializer
    2. we have if/else logic, which is bad
    3. 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
@giohappy giohappy added this to the 4.4.0 milestone Jul 30, 2024
@mattiagiupponi mattiagiupponi linked a pull request Jul 31, 2024 that will close this issue
12 tasks
mattiagiupponi added a commit that referenced this issue Sep 20, 2024
mattiagiupponi added a commit that referenced this issue Sep 20, 2024
mattiagiupponi added a commit that referenced this issue Sep 20, 2024
@giohappy giohappy modified the milestones: 4.4.0, 5.0.0 Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants