[GeoNode-users] Assigning perms to custom layer model
Simone Dalmasso
simone.dalmasso at gmail.com
Mon Nov 21 06:08:45 PST 2016
Hi, I think that geoserver layers permissions are returned for Layer, Map
and Document using
https://github.com/GeoNode/geonode/blob/master/geonode/geoserver/views.py#L463
so
maybe you need to edit that as well.
2016-11-17 4:02 GMT+01:00 Israel López <asralf at gmail.com>:
> Hi dear devs good day
>
> I'm developing a specific app for geonode where I need an alternate layer
> model, I've used the original layer model as example, in general it works
> fine, but the problem is when I want to retrieve the resource via geoserver
> API REST.
>
> It is only available for the admin user or superuser, but not for any
> other user or anonymous,
> could you help me??? how can I assign perms for this new model, I think
> this is the trouble.
>
> Notes:
> I create the Layer from a Postgis view and upload to geoserver with the
> next code:
>
> cat = Catalog(settings.OGC_SERVER['default']['LOCATION'] + "rest",
> _user, _password)
> workspace = cat.get_workspace(settings.DEFAULT_WORKSPACE)
> ds_list = cat.get_xml(workspace.datastore_url)
> datastores = [datastore_from_index(cat, workspace, n) for n in ds_list.findall("dataStore")]
> ds = None
> for datastore in datastores:
> if datastore.name == "datastore":
> ds = datastore
> ft = cat.publish_featuretype(view_name, ds, mun_layer.srid, srs=mun_layer.srid)
> ft.title = layer_title
> cat.save(ft)
>
>
> I create the Layer in Django like this:
>
> signals.pre_save.disconnect(geoserver_pre_save, sender=AlfLayer) #Not sure about this line implementation
> layer, created = AlfLayer.objects.get_or_create(name=view_name, alf_table=alf_table, defaults={
> "workspace": workspace.name,
> "store": ds.name,
> "storeType": ds.resource_type,
> "typename": "%s:%s" % (workspace.name.encode('utf-8'), ft.name.encode('utf-8')),
> "title": ft.title or 'No title provided',
> "uuid": str(uuid.uuid4()),
> "bbox_x0": Decimal(ft.latlon_bbox[0]),
> "bbox_x1": Decimal(ft.latlon_bbox[1]),
> "bbox_y0": Decimal(ft.latlon_bbox[2]),
> "bbox_y1": Decimal(ft.latlon_bbox[3])
> })
> signals.pre_save.connect(geoserver_pre_save, sender=AlfLayer)
>
>
> perm_spec = {
> "users": {
> "AnonymousUser": ["view_resourcebase"]
> },
> "groups": {"anonymous": ["view_resourcebase"]}
> }
>
> layer.set_permissions(perm_spec)
>
>
> Any help is appreciated, in advance so many thanks.
>
>
> _______________________________________________
> geonode-users mailing list
> geonode-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/geonode-users
>
>
--
Simone
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geonode-users/attachments/20161121/918a683c/attachment.html>
More information about the geonode-users
mailing list