geonode.resource.manager

Attributes

logger

resource_manager

Classes

ResourceManagerInterface

ResourceManager

Module Contents

geonode.resource.manager.logger[source]
class geonode.resource.manager.ResourceManagerInterface[source]
abstract search(filter: dict, /, resource_type: object | None) django.db.models.query.QuerySet[source]

Returns a QuerySet of the filtered resources into the DB.

  • The ‘filter’ parameter should be an dictionary with the filtering criteria; - ‘filter’ = None won’t return any result - ‘filter’ = {} will return the whole set

  • The ‘resource_type’ parameter allows to specify the concrete resource model (e.g. Dataset, Document, Map, …) - ‘resource_type’ must be a class - ‘resource_type’ = Dataset will return a set of the only available Layers

abstract exists(uuid: str, /, instance: geonode.base.models.ResourceBase = None) bool[source]

Returns ‘True’ or ‘False’ if the resource exists or not.

  • If ‘instance’ is provided, it will take precedence on ‘uuid’

  • The existance criteria might be subject to the ‘concrete resource manager’ one, dependent on the resource type e.g.: a local Dataset existance check will be constrained by the existance of the layer on the GIS backend

abstract delete(uuid: str, /, instance: geonode.base.models.ResourceBase = None) int[source]

Deletes a resource from the DB.

  • If ‘instance’ is provided, it will take precedence on ‘uuid’

  • It will also fallback to the ‘concrete resource manager’ delete model.

  • This will eventually delete the related resources on the GIS backend too.

abstract create(uuid: str, /, resource_type: object | None = None, defaults: dict = {}) geonode.base.models.ResourceBase[source]

The method will just create a new ‘resource_type’ on the DB model and invoke the ‘post save’ triggers.

  • It assumes any GIS backend resource (e.g. layers on GeoServer) already exist.

  • It is possible to pass initial default values, like the ‘files’ from the ‘storage_manager’ trhgouh the ‘defaults’ dictionary

abstract update(uuid: str, /, instance: geonode.base.models.ResourceBase = None, xml_file: str = None, metadata_uploaded: bool = False, vals: dict = {}, regions: dict = {}, keywords: dict = {}, custom: dict = {}, notify: bool = True) geonode.base.models.ResourceBase[source]

The method will update an existing ‘resource_type’ on the DB model and invoke the ‘post save’ triggers.

  • It assumes any GIS backend resource (e.g. layers on GeoServer) already exist.

  • It is possible to pass initial default values, like the ‘files’ from the ‘storage_manager’ trhgouh the ‘vals’ dictionary

  • The ‘xml_file’ parameter allows to fetch metadata values from a file

  • The ‘notify’ parameter allows to notify the members that the resource has been updated

abstract ingest(files: List[str], /, uuid: str = None, resource_type: object | None = None, defaults: dict = {}, **kwargs) geonode.base.models.ResourceBase[source]

The method allows to create a resource by providing the list of files.

e.g.:

In [1]: from geonode.resource.manager import resource_manager

In [2]: from geonode.layers.models import Dataset

In [3]: from django.contrib.auth import get_user_model

In [4]: admin = get_user_model().objects.get(username=’admin’)

In [5]: files = [“/…/san_andres_y_providencia_administrative.dbf”, “/…/san_andres_y_providencia_administrative.prj”, …: “/…/san_andres_y_providencia_administrative.shx”, “/…/san_andres_y_providencia_administrative.sld”, “/…/san_andres_y_providencia_administrative.shp”]

In [6]: resource_manager.ingest(files, resource_type=Dataset, defaults={‘owner’: admin})

abstract copy(instance: geonode.base.models.ResourceBase, /, uuid: str = None, owner: django.conf.settings.AUTH_USER_MODEL = None, defaults: dict = {}) geonode.base.models.ResourceBase[source]

The method makes a copy of the existing resource.

  • It makes a copy of the files

  • It creates a new layer on the GIS backend in the case the ResourceType is a Dataset

abstract append(instance: geonode.base.models.ResourceBase, vals: dict = {}) geonode.base.models.ResourceBase[source]

The method appends data to an existing resource.

  • It assumes any GIS backend resource (e.g. layers on GeoServer) already exist.

abstract replace(instance: geonode.base.models.ResourceBase, vals: dict = {}) geonode.base.models.ResourceBase[source]

The method replaces data of an existing resource.

  • It assumes any GIS backend resource (e.g. layers on GeoServer) already exist.

abstract exec(method: str, uuid: str, /, instance: geonode.base.models.ResourceBase = None, **kwargs) geonode.base.models.ResourceBase[source]

A generic ‘exec’ method allowing to invoke specific methods of the concrete resource manager not exposed by the interface.

  • The parameter ‘method’ represents the actual name of the concrete method to invoke.

abstract remove_permissions(uuid: str, /, instance: geonode.base.models.ResourceBase = None) bool[source]

Completely cleans the permissions of a resource, resetting it to the default state (owner only)

abstract set_permissions(uuid: str, /, instance: geonode.base.models.ResourceBase = None, owner: django.conf.settings.AUTH_USER_MODEL = None, permissions: dict = {}, created: bool = False, approval_status_changed: bool = False, group_status_changed: bool = False) bool[source]

Sets the permissions of a resource.

  • It optionally gets a JSON ‘perm_spec’ through the ‘permissions’ parameter

  • If no ‘perm_spec’ is provided, it will set the default permissions (owner only)

abstract set_thumbnail(uuid: str, /, instance: geonode.base.models.ResourceBase = None, overwrite: bool = True, check_bbox: bool = True) bool[source]

Allows to generate or re-generate the Thumbnail of a Resource.

class geonode.resource.manager.ResourceManager(concrete_manager=None)[source]

Bases: ResourceManagerInterface

_concrete_resource_manager[source]
_get_concrete_manager()[source]
classmethod _get_instance(uuid: str) geonode.base.models.ResourceBase[source]
search(filter: dict, /, resource_type: object | None) django.db.models.query.QuerySet[source]

Returns a QuerySet of the filtered resources into the DB.

  • The ‘filter’ parameter should be an dictionary with the filtering criteria; - ‘filter’ = None won’t return any result - ‘filter’ = {} will return the whole set

  • The ‘resource_type’ parameter allows to specify the concrete resource model (e.g. Dataset, Document, Map, …) - ‘resource_type’ must be a class - ‘resource_type’ = Dataset will return a set of the only available Layers

exists(uuid: str, /, instance: geonode.base.models.ResourceBase = None) bool[source]

Returns ‘True’ or ‘False’ if the resource exists or not.

  • If ‘instance’ is provided, it will take precedence on ‘uuid’

  • The existance criteria might be subject to the ‘concrete resource manager’ one, dependent on the resource type e.g.: a local Dataset existance check will be constrained by the existance of the layer on the GIS backend

delete(uuid: str, /, instance: geonode.base.models.ResourceBase = None) int[source]

Deletes a resource from the DB.

  • If ‘instance’ is provided, it will take precedence on ‘uuid’

  • It will also fallback to the ‘concrete resource manager’ delete model.

  • This will eventually delete the related resources on the GIS backend too.

create(uuid: str, /, resource_type: object | None = None, defaults: dict = {}) geonode.base.models.ResourceBase[source]

The method will just create a new ‘resource_type’ on the DB model and invoke the ‘post save’ triggers.

  • It assumes any GIS backend resource (e.g. layers on GeoServer) already exist.

  • It is possible to pass initial default values, like the ‘files’ from the ‘storage_manager’ trhgouh the ‘defaults’ dictionary

update(uuid: str, /, instance: geonode.base.models.ResourceBase = None, xml_file: str = None, metadata_uploaded: bool = False, vals: dict = {}, regions: list = [], keywords: list = [], custom: dict = {}, notify: bool = True, extra_metadata: list = [], *args, **kwargs) geonode.base.models.ResourceBase[source]

The method will update an existing ‘resource_type’ on the DB model and invoke the ‘post save’ triggers.

  • It assumes any GIS backend resource (e.g. layers on GeoServer) already exist.

  • It is possible to pass initial default values, like the ‘files’ from the ‘storage_manager’ trhgouh the ‘vals’ dictionary

  • The ‘xml_file’ parameter allows to fetch metadata values from a file

  • The ‘notify’ parameter allows to notify the members that the resource has been updated

ingest(files: List[str], /, uuid: str = None, resource_type: object | None = None, defaults: dict = {}, **kwargs) geonode.base.models.ResourceBase[source]

The method allows to create a resource by providing the list of files.

e.g.:

In [1]: from geonode.resource.manager import resource_manager

In [2]: from geonode.layers.models import Dataset

In [3]: from django.contrib.auth import get_user_model

In [4]: admin = get_user_model().objects.get(username=’admin’)

In [5]: files = [“/…/san_andres_y_providencia_administrative.dbf”, “/…/san_andres_y_providencia_administrative.prj”, …: “/…/san_andres_y_providencia_administrative.shx”, “/…/san_andres_y_providencia_administrative.sld”, “/…/san_andres_y_providencia_administrative.shp”]

In [6]: resource_manager.ingest(files, resource_type=Dataset, defaults={‘owner’: admin})

copy(instance: geonode.base.models.ResourceBase, /, uuid: str = None, owner: django.conf.settings.AUTH_USER_MODEL = None, defaults: dict = {}) geonode.base.models.ResourceBase[source]

The method makes a copy of the existing resource.

  • It makes a copy of the files

  • It creates a new layer on the GIS backend in the case the ResourceType is a Dataset

append(instance: geonode.base.models.ResourceBase, vals: dict = {}, *args, **kwargs)[source]

The method appends data to an existing resource.

  • It assumes any GIS backend resource (e.g. layers on GeoServer) already exist.

replace(instance: geonode.base.models.ResourceBase, vals: dict = {}, *args, **kwargs)[source]

The method replaces data of an existing resource.

  • It assumes any GIS backend resource (e.g. layers on GeoServer) already exist.

_validate_resource(instance: geonode.base.models.ResourceBase, action_type: str) bool[source]
exec(method: str, uuid: str, /, instance: geonode.base.models.ResourceBase = None, **kwargs) geonode.base.models.ResourceBase[source]

A generic ‘exec’ method allowing to invoke specific methods of the concrete resource manager not exposed by the interface.

  • The parameter ‘method’ represents the actual name of the concrete method to invoke.

remove_permissions(uuid: str, /, instance: geonode.base.models.ResourceBase = None) bool[source]

Remove object permissions on given resource. If is a layer removes the layer specific permissions then the resourcebase permissions.

set_permissions(uuid: str, /, instance: geonode.base.models.ResourceBase = None, owner: django.conf.settings.AUTH_USER_MODEL = None, permissions: dict = {}, created: bool = False, approval_status_changed: bool = False, group_status_changed: bool = False) bool[source]

Sets the permissions of a resource.

  • It optionally gets a JSON ‘perm_spec’ through the ‘permissions’ parameter

  • If no ‘perm_spec’ is provided, it will set the default permissions (owner only)

set_thumbnail(uuid: str, /, instance: geonode.base.models.ResourceBase = None, overwrite: bool = True, check_bbox: bool = True, thumbnail=None) bool[source]

Allows to generate or re-generate the Thumbnail of a Resource.

geonode.resource.manager.resource_manager[source]