<div dir="ltr"><div><div><div><div>Hi Paolo,<br><br></div>I removed the try block. The error happens in the first print statement, when it tries to print layer.alternate.<br>It says:<br><font size="2"><span style="font-family:monospace">AttributeError: 'Layer' object has no attribute 'alternate'<br></span><br></font></div><font size="2">I then removed the layer.alternate from the print statement and the sync_geofence command runs. But each time I run it, I get a different number of geofence data rules.<br></font></div><font size="2">I'll try to run the commands in a python interpreter and try to identify what's going on.<br><br></font></div><font size="2">Cheers<br></font><div><div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Mar 6, 2018 at 11:37 AM Paolo Corti <<a href="mailto:pcorti@gmail.com">pcorti@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Daniel<br>
remove the try block, and paste here the error trace stack<br>
ps: to debug with the shell, you must use "django-admin shell" command<br>
(which is "geonode shell" if you are using the Ubuntu package, I<br>
believe)<br>
thanks<br>
Paolo<br>
<br>
On Tue, Mar 6, 2018 at 7:11 AM, Daniel Victoria<br>
<<a href="mailto:daniel.victoria@gmail.com" target="_blank">daniel.victoria@gmail.com</a>> wrote:<br>
> Hi Paolo,<br>
><br>
> There are 2 print statements in the except block. The first prints the error<br>
> and the second is the one that complains about the variable 'perm_spec'<br>
> referenced before assignment.<br>
><br>
> If I comment out just the second print statement I the following message<br>
> printed to the screen, one for each layer registered in GeoServer<br>
><br>
> ('Unexpected error:', <type 'exceptions.AttributeError'>)<br>
><br>
> I tried to run the commands in a python interpreter to debug this. But I<br>
> could not get the environment set. When I import the geonode.layers.models<br>
> in the interpreter, it complains about django_settings_module.<br>
><br>
> Cheers<br>
> Daniel<br>
><br>
> On Mon, Mar 5, 2018 at 10:08 PM Paolo Corti <<a href="mailto:pcorti@gmail.com" target="_blank">pcorti@gmail.com</a>> wrote:<br>
>><br>
>> Hi Daniel<br>
>> can you try to remove the line with the print statement and see what<br>
>> kind of error is raising?<br>
>><br>
>> Paolo<br>
>><br>
>> On Mon, Mar 5, 2018 at 12:26 PM, Daniel Victoria<br>
>> <<a href="mailto:daniel.victoria@gmail.com" target="_blank">daniel.victoria@gmail.com</a>> wrote:<br>
>> > Hi Paolo,<br>
>> ><br>
>> > Thanks for the tip. However, I installed GeoNode from the APT repository<br>
>> > and<br>
>> > I have no idea how to upgrade GeoNode or change GeoFence store from H2<br>
>> > to<br>
>> > PostgreSQL.<br>
>> ><br>
>> > I also added time.sleep(5) in sync_geofence.py, right before the try<br>
>> > block<br>
>> > but I'm still getting an error: It fails with the message:<br>
>> ><br>
>> > ('Unexpected error:', <type 'exceptions.AttributeError'>)<br>
>> > Traceback (most recent call last):<br>
>> > File "/usr/bin/django-admin", line 21, in <module><br>
>> > management.execute_from_command_line()<br>
>> > File<br>
>> > "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py",<br>
>> > line<br>
>> > 354, in execute_from_command_line<br>
>> > utility.execute()<br>
>> > File<br>
>> > "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py",<br>
>> > line<br>
>> > 346, in execute<br>
>> > self.fetch_command(subcommand).run_from_argv(self.argv)<br>
>> > File<br>
>> > "/usr/lib/python2.7/dist-packages/django/core/management/base.py",<br>
>> > line 394, in run_from_argv<br>
>> > self.execute(*args, **cmd_options)<br>
>> > File<br>
>> > "/usr/lib/python2.7/dist-packages/django/core/management/base.py",<br>
>> > line 445, in execute<br>
>> > output = self.handle(*args, **options)<br>
>> > File<br>
>> ><br>
>> > "/usr/local/lib/python2.7/dist-packages/geonode/geoserver/management/commands/sync_geofence.py",<br>
>> > line 60, in handle<br>
>> > print 'perm_spec is %s' % perm_spec<br>
>> > UnboundLocalError: local variable 'perm_spec' referenced before<br>
>> > assignment<br>
>> ><br>
>> > Any other tips on how to fix this permission mess-up?<br>
>> ><br>
>> > Thanks<br>
>> > Daniel<br>
>> ><br>
>> > On Mon, Mar 5, 2018 at 12:13 PM Paolo Corti <<a href="mailto:pcorti@gmail.com" target="_blank">pcorti@gmail.com</a>> wrote:<br>
>> >><br>
>> >> Another option could be to run a time.sleep for some seconds after<br>
>> >> each layer iteration in sync_geofence command<br>
>> >> cheers<br>
>> >> Paolo<br>
>> >><br>
>> >> On Mon, Mar 5, 2018 at 10:04 AM, Paolo Corti <<a href="mailto:pcorti@gmail.com" target="_blank">pcorti@gmail.com</a>> wrote:<br>
>> >> > Hi Daniel<br>
>> >> ><br>
>> >> > You seem to have hit this bug which I reported to GeoFence team in<br>
>> >> > the<br>
>> >> > past:<br>
>> >> > <a href="https://github.com/geoserver/geofence/issues/98" rel="noreferrer" target="_blank">https://github.com/geoserver/geofence/issues/98</a><br>
>> >> ><br>
>> >> > I didn't notice this happening in latest GeoFence version, so<br>
>> >> > upgrading to latest GeoNode could be an option.<br>
>> >> > Or you could try to use PostgreSQL instead than H2 as a GeoFence<br>
>> >> > store<br>
>> >> ><br>
>> >> > hope this helps<br>
>> >> ><br>
>> >> > cheers<br>
>> >> > Paolo<br>
>> >> ><br>
>> >> > On Mon, Mar 5, 2018 at 9:19 AM, Daniel Victoria<br>
>> >> > <<a href="mailto:daniel.victoria@gmail.com" target="_blank">daniel.victoria@gmail.com</a>> wrote:<br>
>> >> >> Update: Apparently, if I update the layer permissions in the web<br>
>> >> >> interface<br>
>> >> >> or if i run `geonode updatelayers -f <layer_name>`, the correct<br>
>> >> >> GeoFence<br>
>> >> >> permissions are created. Thus, doing so a layer at a time works. But<br>
>> >> >> several<br>
>> >> >> layers at once, no.<br>
>> >> >><br>
>> >> >> What should I look for in the GeoServer log to try to figure out<br>
>> >> >> where<br>
>> >> >> the<br>
>> >> >> problem is occurring? I can attach the GeoServer log if that helps.<br>
>> >> >><br>
>> >> >> Cheers<br>
>> >> >> Daniel<br>
>> >> >><br>
>> >> >> On Mon, Mar 5, 2018 at 9:52 AM Daniel Victoria<br>
>> >> >> <<a href="mailto:daniel.victoria@gmail.com" target="_blank">daniel.victoria@gmail.com</a>><br>
>> >> >> wrote:<br>
>> >> >>><br>
>> >> >>> Hi list,<br>
>> >> >>><br>
>> >> >>> I have GeoNode 2.6.3, installed from apt, in a Ubuntu machine.<br>
>> >> >>> Right<br>
>> >> >>> now i<br>
>> >> >>> have 108 registered layers, some imported using the web interface,<br>
>> >> >>> some<br>
>> >> >>> using the `geonode importlayers` command.<br>
>> >> >>><br>
>> >> >>> Last week I noticed that some of the layers I was importing using<br>
>> >> >>> the<br>
>> >> >>> management command had view permission problems. I realized that<br>
>> >> >>> the<br>
>> >> >>> cause<br>
>> >> >>> was that the GeoFence rules were not being created correctly.<br>
>> >> >>><br>
>> >> >>> Looking at the messages on the list, I saw that there were some<br>
>> >> >>> discussions about this issue and that 1) there was a patch for<br>
>> >> >>> geoserver/helper.py [1] and 2) a new `sync_geofence` management<br>
>> >> >>> command.<br>
>> >> >>><br>
>> >> >>> I applied the patch and downloaded the `sync_geofence` command.<br>
>> >> >>><br>
>> >> >>> Now, every time I run `geonode updatelayers` I end up with a<br>
>> >> >>> different<br>
>> >> >>> set<br>
>> >> >>> of rules in GeoFence. Some times with 106 rules, some times with<br>
>> >> >>> 209<br>
>> >> >>> rules<br>
>> >> >>> etc. And I can't run `geonode sync_geofence` since I'm getting an<br>
>> >> >>> error:<br>
>> >> >>><br>
>> >> >>> UnboundLocalError: local variable 'perm_spec' referenced before<br>
>> >> >>> assignment<br>
>> >> >>><br>
>> >> >>> Any idea how to fix this issue so I don't have to manually create<br>
>> >> >>> the<br>
>> >> >>> GeoFence rules? And also, not have `geonode updatelayers` mess up<br>
>> >> >>> the<br>
>> >> >>> rules<br>
>> >> >>> already created?<br>
>> >> >>><br>
>> >> >>> Cheers<br>
>> >> >>> Daniel<br>
>> >> >>><br>
>> >> >>> [1] -<br>
>> >> >>><br>
>> >> >>><br>
>> >> >>> <a href="https://github.com/GeoNode/geonode/commit/94b3b6abfd1bc856be94eb58f5bf13" rel="noreferrer" target="_blank">https://github.com/GeoNode/geonode/commit/94b3b6abfd1bc856be94eb58f5bf13</a><br>
>> >> >><br>
>> >> >><br>
>> >> >> _______________________________________________<br>
>> >> >> geonode-users mailing list<br>
>> >> >> <a href="mailto:geonode-users@lists.osgeo.org" target="_blank">geonode-users@lists.osgeo.org</a><br>
>> >> >> <a href="https://lists.osgeo.org/mailman/listinfo/geonode-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/geonode-users</a><br>
>> >> >><br>
>> >> ><br>
>> >> ><br>
>> >> ><br>
>> >> > --<br>
>> >> > Paolo Corti<br>
>> >> > Geospatial software developer<br>
>> >> > web: <a href="http://www.paolocorti.net" rel="noreferrer" target="_blank">http://www.paolocorti.net</a><br>
>> >> > twitter: @capooti<br>
>> >> > skype: capooti<br>
>> >><br>
>> >><br>
>> >><br>
>> >> --<br>
>> >> Paolo Corti<br>
>> >> Geospatial software developer<br>
>> >> web: <a href="http://www.paolocorti.net" rel="noreferrer" target="_blank">http://www.paolocorti.net</a><br>
>> >> twitter: @capooti<br>
>> >> skype: capooti<br>
>><br>
>><br>
>><br>
>> --<br>
>> Paolo Corti<br>
>> Geospatial software developer<br>
>> web: <a href="http://www.paolocorti.net" rel="noreferrer" target="_blank">http://www.paolocorti.net</a><br>
>> twitter: @capooti<br>
>> skype: capooti<br>
<br>
<br>
<br>
--<br>
Paolo Corti<br>
Geospatial software developer<br>
web: <a href="http://www.paolocorti.net" rel="noreferrer" target="_blank">http://www.paolocorti.net</a><br>
twitter: @capooti<br>
skype: capooti<br>
</blockquote></div>