[GeoNode-users] Assigning perms to custom layer model

Israel López asralf at gmail.com
Wed Nov 16 19:02:09 PST 2016


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geonode-users/attachments/20161116/8c9d52f1/attachment.html>


More information about the geonode-users mailing list