-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Fixes #14309] Generalize remote service type registration and auth handling #14328
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
Open
sijandh35
wants to merge
7
commits into
master
Choose a base branch
from
ISSUE_14309
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2b22b73
[Fixes #14309] Generalize remote service type registration and auth h…
sijandh35 12f23eb
[Fixes #14309] fixes review suggestions
sijandh35 b9f3de5
Merge branch 'master' into ISSUE_14309
sijandh35 6584bb3
[Fixes #14309] update test case failure
sijandh35 5203082
[Fixes #14309] fixes review comment
sijandh35 0402c64
[Fixes #14309] update review suggestions
sijandh35 71b81af
[Fixes #14309] update redundant service fallback and related test
sijandh35 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Generated by Django 5.2.15 on 2026-06-09 12:56 | ||
|
|
||
| import geonode.services.models | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ("services", "0059_remove_service_password_remove_service_username"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name="service", | ||
| name="type", | ||
| field=models.CharField(choices=geonode.services.models.get_service_type_choices, max_length=10), | ||
| ), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| ######################################################################### | ||
| # | ||
| # Copyright (C) 2026 OSGeo | ||
| # | ||
| # This program is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| # | ||
| ######################################################################### | ||
| from collections import OrderedDict | ||
|
|
||
| from django.conf import settings | ||
| from django.utils.module_loading import import_string | ||
| from django.utils.translation import gettext_lazy as _ | ||
|
|
||
| from geonode.services import enumerations | ||
|
|
||
|
|
||
| class ServiceTypeRegistry: | ||
| def __init__(self): | ||
| self.registry = OrderedDict() | ||
| self._initialized = False | ||
|
|
||
| def register(self, service_type, handler, label, OWS=False, **kwargs): | ||
| self.registry[service_type] = { | ||
| "OWS": OWS, | ||
| "handler": handler, | ||
| "label": label, | ||
| **kwargs, | ||
| } | ||
|
|
||
| def unregister(self, service_type): | ||
| self.registry.pop(service_type, None) | ||
|
|
||
| def init_registry(self): | ||
| if self._initialized: | ||
| return | ||
|
|
||
| self.registry = OrderedDict() | ||
| self._register_default_service_types() | ||
| self._register_configured_service_types() | ||
| self._initialized = True | ||
|
|
||
| def reset(self): | ||
| self.registry = OrderedDict() | ||
| self._initialized = False | ||
|
|
||
| def get_available_service_types(self): | ||
| self.init_registry() | ||
| return OrderedDict(self.registry) | ||
|
|
||
| def get_handler_class(self, service_type): | ||
| service_type_config = self.get_available_service_types().get(service_type, {}) | ||
| handler = service_type_config.get("handler") | ||
| if isinstance(handler, str): | ||
| return import_string(handler) | ||
| return handler | ||
|
|
||
| def _register_default_service_types(self): | ||
| # Keep imports lazy to avoid circular imports during Django app loading. | ||
| from geonode.services.serviceprocessors.arcgis import ArcImageServiceHandler, ArcMapServiceHandler | ||
| from geonode.services.serviceprocessors.wms import GeoNodeServiceHandler, WmsServiceHandler | ||
|
|
||
| self.register(enumerations.WMS, WmsServiceHandler, _("Web Map Service"), OWS=True) | ||
| self.register(enumerations.GN_WMS, GeoNodeServiceHandler, _("GeoNode (Web Map Service)"), OWS=True) | ||
| self.register(enumerations.REST_MAP, ArcMapServiceHandler, _("ArcGIS REST MapServer")) | ||
| self.register(enumerations.REST_IMG, ArcImageServiceHandler, _("ArcGIS REST ImageServer")) | ||
|
|
||
| def _register_configured_service_types(self): | ||
| for service_type_module_path in getattr(settings, "SERVICES_TYPE_MODULES", []): | ||
| custom_service_type_module = import_string(service_type_module_path) | ||
| for service_type, service_type_config in custom_service_type_module.services_type.items(): | ||
| self.register(service_type, **service_type_config) | ||
|
|
||
|
|
||
| service_type_registry = ServiceTypeRegistry() | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.