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

Layer UUID hook #6952

Closed
mattiagiupponi opened this issue Feb 15, 2021 · 2 comments
Closed

Layer UUID hook #6952

mattiagiupponi opened this issue Feb 15, 2021 · 2 comments
Assignees
Labels
feature A new feature to be added to the codebase
Milestone

Comments

@mattiagiupponi
Copy link
Contributor

mattiagiupponi commented Feb 15, 2021

The current generation of the UUID for the Layers is based on those two lines:

instance.uuid = str(uuid.uuid1()) in geonode/geonode/layers/models.py
layer_uuid = str(uuid.uuid1()) in geonode/geonode/upload/upload.py

We want to let the UUID creation be pluggable and let the user use his own UUID generator based on their needs.

if hasattr(settings, 'LAYER_UUID_HANDLER') and settings.LAYER_UUID_HANDLER != '':
        from geonode.layers.utils import get_uuid_handler
        instance.uuid = get_uuid_handler()(instance).create_uuid()

And is enough to add this config in settings.py by specifying the object that is responsible to manage the new UUID

LAYER_UUID_HANDLER = "mymodule.myfile.MyObject"

More information related to the configuration are available in this PR

Documentation PR at this link

@mattiagiupponi mattiagiupponi added the feature A new feature to be added to the codebase label Feb 15, 2021
@mattiagiupponi mattiagiupponi self-assigned this Feb 15, 2021
@gannebamm
Copy link
Contributor

Will this interfere with #6711?

@mattiagiupponi
Copy link
Contributor Author

Hey, @gannebamm thanks for the comment.
As you can see in this part of the code (pr)

if hasattr(settings, 'LAYER_UUID_HANDLER') and settings.LAYER_UUID_HANDLER != '':
logger.debug("using custom uuid handler In pre_save_layer")
from geonode.layers.utils import get_uuid_handler
instance.uuid = get_uuid_handler()(instance).create_uuid()
else:
if instance.uuid == '':
instance.uuid = str(uuid.uuid1())

The UUID will change only if a new handler is defined, otherwise will continue using the old version of the UUID
As far as I can see, the #6711 should not impact your development, but I don't have enough context on it, because from the code of the utils.py looks like that the UUID is read from the XML file and not defined on run-time.
So, if you decide to override the way to save the UUID (since is a Charfield could be anything) if you upload the metadata you (user) should have enough context of what's going on.
This is just an observation, maybe @afabiani could help us more :)

mattiagiupponi added a commit to geosolutions-it/geonode that referenced this issue Feb 16, 2021
@afabiani afabiani added this to the 4.0.0 milestone Jul 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature to be added to the codebase
Projects
None yet
Development

No branches or pull requests

3 participants