<div dir="ltr">Hi, I think that geoserver layers permissions are returned for Layer, Map and Document using <a href="https://github.com/GeoNode/geonode/blob/master/geonode/geoserver/views.py#L463">https://github.com/GeoNode/geonode/blob/master/geonode/geoserver/views.py#L463</a> so maybe you need to edit that as well.</div><div class="gmail_extra"><br><div class="gmail_quote">2016-11-17 4:02 GMT+01:00 Israel López <span dir="ltr"><<a href="mailto:asralf@gmail.com" target="_blank">asralf@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi dear devs good day<div><br></div><div>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.<div><br></div><div>It is only available for the admin user or superuser, but not for any other user or anonymous, </div><div>could you help me??? how can I assign perms for this new model, I think this is the trouble.</div><div><br></div><div>Notes:</div><div>I create the Layer from a Postgis view and upload to geoserver with the next code:</div><div><br></div><div><pre style="color:rgb(0,0,0);font-family:"dejavu sans mono";font-size:9pt">cat = Catalog(settings.OGC_SERVER[<span style="color:rgb(0,128,0);font-weight:bold">'<wbr>default'</span>][<span style="color:rgb(0,128,0);font-weight:bold">'LOCATION'</span>] + <span style="color:rgb(0,128,0);font-weight:bold">"rest"</span>,<br> _user, _password)<br>workspace = cat.get_workspace(settings.<wbr>DEFAULT_WORKSPACE)<br>ds_list = cat.get_xml(workspace.<wbr>datastore_url)<br>datastores = [datastore_from_index(cat, workspace, n) <span style="color:rgb(0,0,128);font-weight:bold">for </span>n <span style="color:rgb(0,0,128);font-weight:bold">in </span>ds_list.findall(<span style="color:rgb(0,128,0);font-weight:bold">"dataStore"</span>)]<br>ds = <span style="background-color:rgb(228,228,255)">None</span><br><span style="color:rgb(0,0,128);font-weight:bold">for </span>datastore <span style="color:rgb(0,0,128);font-weight:bold">in </span>datastores:<br> <span style="color:rgb(0,0,128);font-weight:bold">if </span><a href="http://datastore.name" target="_blank">datastore.name</a> == <span style="color:rgb(0,128,0);font-weight:bold">"datastore"</span>:<br> ds = datastore<br>ft = cat.publish_featuretype(view_<wbr>name, ds, mun_layer.srid, <span style="color:rgb(102,0,153)">srs</span>=mun_layer.srid)<br>ft.title = layer_title<br>cat.save(ft)</pre><pre style="color:rgb(0,0,0);font-family:"dejavu sans mono";font-size:9pt"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;white-space:normal"><br></span></pre><pre style="color:rgb(0,0,0);font-family:"dejavu sans mono";font-size:9pt"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;white-space:normal">I create the Layer in Django like this:</span><br></pre><pre style="color:rgb(0,0,0);font-family:"dejavu sans mono";font-size:9pt"><pre style="font-family:"dejavu sans mono";font-size:9pt">signals.pre_save.disconnect(<wbr>geoserver_pre_save, <span style="color:rgb(102,0,153)">sender</span>=AlfLayer) #Not sure about this line implementation<br>layer, created = AlfLayer.objects.get_or_<wbr>create(<span style="color:rgb(102,0,153)">name</span>=view_name, <span style="color:rgb(102,0,153)">alf_table</span>=alf_table, <span style="color:rgb(102,0,153)">defaults</span>={<br> <span style="color:rgb(0,128,0);font-weight:bold">"workspace"</span>: <a href="http://workspace.name" target="_blank">workspace.name</a>,<br> <span style="color:rgb(0,128,0);font-weight:bold">"store"</span>: <a href="http://ds.name" target="_blank">ds.name</a>,<br> <span style="color:rgb(0,128,0);font-weight:bold">"storeType"</span>: ds.resource_type,<br> <span style="color:rgb(0,128,0);font-weight:bold">"typename"</span>: <span style="color:rgb(0,128,0);font-weight:bold">"%s:%s" </span>% (workspace.name.encode(<span style="color:rgb(0,128,0);font-weight:bold">'utf-8'</span><wbr>), ft.name.encode(<span style="color:rgb(0,128,0);font-weight:bold">'utf-8'</span>)),<br> <span style="color:rgb(0,128,0);font-weight:bold">"title"</span>: ft.title <span style="color:rgb(0,0,128);font-weight:bold">or </span><span style="color:rgb(0,128,0);font-weight:bold">'No title provided'</span>,<br> <span style="color:rgb(0,128,0);font-weight:bold">"uuid"</span>: <span style="color:rgb(0,0,128)">str</span>(uuid.uuid4()),<br> <span style="color:rgb(0,128,0);font-weight:bold">"bbox_x0"</span>: Decimal(ft.latlon_bbox[<span style="color:rgb(0,0,255)">0</span>]),<br> <span style="color:rgb(0,128,0);font-weight:bold">"bbox_x1"</span>: Decimal(ft.latlon_bbox[<span style="color:rgb(0,0,255)">1</span>]),<br> <span style="color:rgb(0,128,0);font-weight:bold">"bbox_y0"</span>: Decimal(ft.latlon_bbox[<span style="color:rgb(0,0,255)">2</span>]),<br> <span style="color:rgb(0,128,0);font-weight:bold">"bbox_y1"</span>: Decimal(ft.latlon_bbox[<span style="color:rgb(0,0,255)">3</span>])<br>})<br>signals.pre_save.connect(<wbr>geoserver_pre_save, <span style="color:rgb(102,0,153)">sender</span>=AlfLayer)<br><span style="color:rgb(128,128,128);font-style:italic"><br></span><span style="color:rgb(128,128,128);font-style:italic"><br></span>perm_spec = {<br> <span style="color:rgb(0,128,0);font-weight:bold">"users"</span>: {<span style="color:rgb(128,128,128);font-style:italic"><br></span><span style="color:rgb(128,128,128);font-style:italic"> </span><span style="color:rgb(0,128,0);font-weight:bold">"AnonymousUser"</span>: [<span style="color:rgb(0,128,0);font-weight:bold">"view_resourcebase"</span>]<br> },<br> <span style="color:rgb(0,128,0);font-weight:bold">"groups"</span>: {<span style="color:rgb(0,128,0);font-weight:bold">"anonymous"</span>: [<span style="color:rgb(0,128,0);font-weight:bold">"view_resourcebase"</span>]}<br>}<br><br>layer.set_permissions(perm_<wbr>spec)</pre><pre style="font-family:"dejavu sans mono";font-size:9pt"><br></pre><pre style="font-family:"dejavu sans mono";font-size:9pt">Any help is appreciated, in advance so many thanks.</pre></pre></div></div></div>
<br>______________________________<wbr>_________________<br>
geonode-users mailing list<br>
<a href="mailto:geonode-users@lists.osgeo.org">geonode-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/geonode-users" rel="noreferrer" target="_blank">http://lists.osgeo.org/<wbr>mailman/listinfo/geonode-users</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Simone </div>
</div>