[GeoNode-devel] GeoNode Project: Timeout updates Layer with new ManyToManyField in ResourceBase
Giambattista Mameli
mameli.giambattista at gmail.com
Wed Oct 23 08:46:05 PDT 2019
Hi guys,
I finally solved the problem.
I was missing the last step in my implementation: convert the domain_area
array into a string before send it to GeoServer
Right now i modified the CORE of GeoNode, but i think i can move everything
on the GeoNode Project
On “geonode.social.signals”, i added the following to the function
“json_serializer_producer”:
….
if 'domain_area' in dictionary.keys():
keys = dictionary['domain_area']
dictionary['domain_area'] = str(keys)
….
Thank you all for the help
gb.
Il giorno mer 23 ott 2019 alle ore 09:46 Giambattista Mameli <
mameli.giambattista at gmail.com> ha scritto:
> Hi Alessio and Amedeo,
> thank you very much for the answers provided.
>
> Amedeo, the answer is YES. The relationship is M:M and it can be done in
> both ways. I followed the "add_class" path because i do not want to modifiy
> the "CORE", and keep the implementations only on the Geonode Project
> Module. Since the ResourceBase is part of the CORE, i recall the class from
> the Project and add the new relationship...
>
> For the update: when i modify data i do not recreate the layer, but only
> the associated INFOs. The integrated authorization works well.
>
> Alessio, can you give me more hints about the "signal interception"?
>
> Il giorno mar 22 ott 2019 alle ore 15:39 Amedeo Fadini <amefad at gmail.com>
> ha scritto:
>
>>
>>
>> Hi Giambattista and welcome in the dev list
>>
>> Thank-you Alessio for the quick response.
>>
>> I have a question just to learn something new: is it the same thing to
>> define the M2M relation on the new object side or use add_class to resource
>> base like in this class?
>>
>> I see in Giambattista log the line
>>
>> producer.geoserver_upload_layer(payload)
>>
>> Giambattista: does the update operation imply the creation or replacement
>> of the layer related to domain_area?
>>
>> If this is the case have you checked that integrated authentication
>> between geonode and geoserver is working as expected?
>>
>> Amedeo Fadini
>>
>>
>>
>> Il giorno mar 22 ott 2019 alle ore 11:20 Alessio Fabiani <
>> alessio.fabiani at geo-solutions.it> ha scritto:
>>
>>> Hi,
>>> most probably you are hitting the post-save signal on ResourceBase
>>> indefinitely.
>>>
>>> You should intercept the signal method and updating the resource base
>>> only in the case you are adding the the m2m relationship a new ResourceBase.
>>>
>>> Il giorno lun 21 ott 2019 alle ore 18:06 Giambattista Mameli <
>>> mameli.giambattista at gmail.com> ha scritto:
>>>
>>>>
>>>> Hi guys,
>>>> I developed a custom GeoNode Project implementing a M:M relationship on
>>>> the ResourceBase table
>>>>
>>>> Here the steps:
>>>>
>>>> 1) model creation of the new table
>>>>
>>>> class DomainArea(models.Model):
>>>>
>>>> identifier = models.CharField('Domain Area name', max_length=255, unique=True)
>>>> description = models.TextField(default='')
>>>> gn_description = models.TextField(
>>>> 'GeoNode description', default='', null=True)
>>>> is_choice = models.BooleanField(default=True)
>>>>
>>>> def __unicode__(self):
>>>> return u"{0}".format(self.gn_description)
>>>>
>>>> class Meta:
>>>> ordering = ("identifier",)
>>>> verbose_name_plural = 'Domain Areas'
>>>>
>>>> 2) add the relation between the ResourceBase table and the new created
>>>> table
>>>>
>>>> domainarea = models.ManyToManyField(
>>>> DomainArea,
>>>> related_name='resourcebase_domainarea',
>>>> blank=True)
>>>> ResourceBase.add_to_class('domain_area', domainarea)
>>>>
>>>> 3) Add the function to handle the new value in the admin panel
>>>>
>>>> admin.site.register(DomainArea)
>>>>
>>>> All the steps work good, Django creates the new table with all the
>>>> relationship and I can handle via admin panel both values and associations
>>>> between domain areas and Layers/Docs/Maps.
>>>>
>>>> The problem is when I modify these values.
>>>>
>>>> After the first association, all the updates go wrong (timeout, even
>>>> with a very long timeout set).
>>>>
>>>> This is the error message:
>>>>
>>>> *******
>>>> Traceback:
>>>>
>>>> File
>>>> "/usr/local/lib/python2.7/site-packages/django/core/handlers/exception.py"
>>>> in inner
>>>> 41. response = get_response(request)
>>>>
>>>> File
>>>> "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py" in
>>>> _legacy_get_response
>>>> 249. response = self._get_response(request)
>>>>
>>>> File
>>>> "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py" in
>>>> _get_response
>>>> 187. response =
>>>> self.process_exception_by_middleware(e, request)
>>>>
>>>> File
>>>> "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py" in
>>>> _get_response
>>>> 185. response = wrapped_callback(request,
>>>> callback_args, *callback_kwargs)
>>>>
>>>> File
>>>> "/usr/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in
>>>> wrapper
>>>> 552. return self.admin_site.admin_view(view)(*args,
>>>> **kwargs)
>>>>
>>>> File
>>>> "/usr/local/lib/python2.7/site-packages/django/utils/decorators.py" in
>>>> _wrapped_view
>>>> 149. response = view_func(request, args, *kwargs)
>>>>
>>>> File
>>>> "/usr/local/lib/python2.7/site-packages/django/views/decorators/cache.py"
>>>> in _wrapped_view_func
>>>> 57. response = view_func(request, args, *kwargs)
>>>>
>>>> File
>>>> "/usr/local/lib/python2.7/site-packages/django/contrib/admin/sites.py" in
>>>> inner
>>>> 224. return view(request, args, *kwargs)
>>>>
>>>> File
>>>> "/usr/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in
>>>> change_view
>>>> 1512. return self.changeform_view(request, object_id,
>>>> form_url, extra_context)
>>>>
>>>> File
>>>> "/usr/local/lib/python2.7/site-packages/django/utils/decorators.py" in
>>>> _wrapper
>>>> 67. return bound_func(*args, **kwargs)
>>>>
>>>> File
>>>> "/usr/local/lib/python2.7/site-packages/django/utils/decorators.py" in
>>>> _wrapped_view
>>>> 149. response = view_func(request, args, *kwargs)
>>>>
>>>> File
>>>> "/usr/local/lib/python2.7/site-packages/django/utils/decorators.py" in
>>>> bound_func
>>>> 63. return func.__get__(self, type(self))(*args2,
>>>> **kwargs2)
>>>>
>>>> File
>>>> "/usr/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in
>>>> changeform_view
>>>> 1409. return self._changeform_view(request, object_id,
>>>> form_url, extra_context)
>>>>
>>>> File
>>>> "/usr/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in
>>>> _changeform_view
>>>> 1449. self.save_model(request, new_object, form, not
>>>> add)
>>>>
>>>> File
>>>> "/usr/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in
>>>> save_model
>>>> 980. obj.save()
>>>>
>>>> File "/usr/local/lib/python2.7/site-packages/polymorphic/models.py" in
>>>> save
>>>> 83. return super(PolymorphicModel, self).save(*args, **kwargs)
>>>>
>>>> File "/usr/local/lib/python2.7/site-packages/django/db/models/base.py"
>>>> in save
>>>> 808. force_update=force_update,
>>>> update_fields=update_fields)
>>>>
>>>> File "/usr/local/lib/python2.7/site-packages/django/db/models/base.py"
>>>> in save_base
>>>> 848. update_fields=update_fields, raw=raw,
>>>> using=using,
>>>>
>>>> File
>>>> "/usr/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py" in
>>>> send
>>>> 193. for receiver in self._live_receivers(sender)
>>>>
>>>> File "/usr/local/lib/python2.7/site-packages/geonode/decorators.py" in
>>>> wrapper
>>>> 53. return func(*args, **kwargs)
>>>>
>>>> File
>>>> "/usr/local/lib/python2.7/site-packages/geonode/geoserver/signals.py" in
>>>> geoserver_post_save
>>>> 85. producer.geoserver_upload_layer(payload)
>>>>
>>>> File
>>>> "/usr/local/lib/python2.7/site-packages/geonode/messaging/producer.py" in
>>>> sync_if_local_memory
>>>> 71. worker.run(timeout=broker_socket_timeout)
>>>>
>>>> File "/usr/local/lib/python2.7/site-packages/kombu/mixins.py" in run
>>>> 170. for _ in self.consume(limit=None, **kwargs):
>>>>
>>>> File "/usr/local/lib/python2.7/site-packages/kombu/mixins.py" in consume
>>>> 192. conn.drain_events(timeout=safety_interval)
>>>>
>>>> File "/usr/local/lib/python2.7/site-packages/kombu/connection.py" in
>>>> drain_events
>>>> 315. return self.transport.drain_events(self.connection,
>>>> **kwargs)
>>>>
>>>> File
>>>> "/usr/local/lib/python2.7/site-packages/kombu/transport/virtual/base.py" in
>>>> drain_events
>>>> 966. raise socket.timeout()
>>>> *****
>>>>
>>>> Any help will be greatly appreciated
>>>>
>>>> Thanks in advance
>>>>
>>>> _______________________________________________
>>>> geonode-devel mailing list
>>>> geonode-devel at lists.osgeo.org
>>>> https://lists.osgeo.org/mailman/listinfo/geonode-devel
>>>>
>>>
>>>
>>> --
>>>
>>> ==
>>>
>>> GeoServer Professional Services from the experts! Visit
>>> http://goo.gl/it488V for more information.
>>> ==
>>> Ing. Alessio Fabiani
>>>
>>> @alfa7691
>>> Founder/Technical Lead
>>>
>>>
>>> GeoSolutions S.A.S.
>>> Via di Montramito 3/A - 55054 Massarosa (LU) - Italy
>>> phone: +39 0584 962313
>>> fax: +39 0584 1660272
>>> mob: +39 331 6233686
>>>
>>>
>>> http://www.geo-solutions.it
>>> http://twitter.com/geosolutions_it
>>> -------------------------------------------------------
>>>
>>> Con riferimento alla normativa sul trattamento dei dati personali (Reg.
>>> UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si
>>> precisa che ogni circostanza inerente alla presente email (il suo
>>> contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è
>>> riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il
>>> messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra
>>> operazione è illecita. Le sarei comunque grato se potesse darmene notizia.
>>>
>>>
>>> This email is intended only for the person or entity to which it is
>>> addressed and may contain information that is privileged, confidential or
>>> otherwise protected from disclosure. We remind that - as provided by
>>> European Regulation 2016/679 “GDPR” - copying, dissemination or use of this
>>> e-mail or the information herein by anyone other than the intended
>>> recipient is prohibited. If you have received this email by mistake, please
>>> notify us immediately by telephone or e-mail.
>>> _______________________________________________
>>> geonode-devel mailing list
>>> geonode-devel at lists.osgeo.org
>>> https://lists.osgeo.org/mailman/listinfo/geonode-devel
>>>
>>
>
> --
> --
>
> Giambattista Mameli
> Web Developer, WebGIS
> E-mail: info at giambattistamameli.it
> Web: http://www.giambattistamameli.it
>
--
--
Giambattista Mameli
Web Developer, WebGIS
E-mail: info at giambattistamameli.it
Web: http://www.giambattistamameli.it
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geonode-devel/attachments/20191023/62b26486/attachment-0001.html>
More information about the geonode-devel
mailing list