GeotrekCE / Geotrek-admin

Paths management for National Parks and Tourism organizations
https://geotrek.fr
BSD 2-Clause "Simplified" License
136 stars 76 forks source link

Prevent intervention to have none topology #1276

Open camillemonchicourt opened 10 years ago

camillemonchicourt commented 10 years ago

I regulary receive this error emails (each day). EDIT : This is not an email received each day but when users try to edit an INTERVENTION. Any idea what it means ?

Email title : [Geotrek] ERROR (EXTERNAL IP): Internal Server Error: /intervention/edit/208/

Email content : Traceback (most recent call last):

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/core/handlers/base.py", line 137, in get_response response = response.render()

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/response.py", line 105, in render self.content = self.rendered_content

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/response.py", line 82, in rendered_content content = template.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 140, in render return self._render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 134, in _render return self.nodelist.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 840, in render bit = self.render_node(node, context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 854, in render_node return node.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/loader_tags.py", line 123, in render return compiled_parent._render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 134, in _render return self.nodelist.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 840, in render bit = self.render_node(node, context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 854, in render_node return node.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/loader_tags.py", line 123, in render return compiled_parent._render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 134, in _render return self.nodelist.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 840, in render bit = self.render_node(node, context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 854, in render_node return node.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/loader_tags.py", line 62, in render result = block.nodelist.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 840, in render bit = self.render_node(node, context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 854, in render_node return node.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/loader_tags.py", line 62, in render result = block.nodelist.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 840, in render bit = self.render_node(node, context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 854, in render_node return node.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/loader_tags.py", line 62, in render result = block.nodelist.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 840, in render bit = self.render_node(node, context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 854, in render_node return node.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/loader_tags.py", line 62, in render result = block.nodelist.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 840, in render bit = self.render_node(node, context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 854, in render_node return node.render(context)

File "/home/sentiers/Geotrek/lib/eggs/django_crispy_forms-1.2.3-py2.7.egg/crispy_forms/templatetags/crispy_forms_tags.py", line 196, in render c = self.get_render(context)

File "/home/sentiers/Geotrek/lib/eggs/django_crispy_forms-1.2.3-py2.7.egg/crispy_forms/templatetags/crispy_forms_tags.py", line 123, in get_render actual_form.form_html = helper.render_layout(actual_form, node_context, template_pack=self.template_pack)

File "/home/sentiers/Geotrek/lib/eggs/django_crispy_forms-1.2.3-py2.7.egg/crispy_forms/helper.py", line 265, in render_layout template_pack=template_pack)

File "/home/sentiers/Geotrek/lib/eggs/django_crispy_forms-1.2.3-py2.7.egg/crispy_forms/layout.py", line 124, in render context, template_pack=template_pack)

File "/home/sentiers/Geotrek/lib/eggs/django_crispy_forms-1.2.3-py2.7.egg/crispy_forms/utils.py", line 48, in render_field return field.render(form, form_style, context, template_pack=template_pack)

File "/home/sentiers/Geotrek/lib/eggs/django_crispy_forms-1.2.3-py2.7.egg/crispy_forms/layout.py", line 416, in render fields += render_field(field, form, form_style, context, template_pack=template_pack)

File "/home/sentiers/Geotrek/lib/eggs/django_crispy_forms-1.2.3-py2.7.egg/crispy_forms/utils.py", line 48, in render_field return field.render(form, form_style, context, template_pack=template_pack)

File "/home/sentiers/Geotrek/lib/eggs/django_crispy_forms-1.2.3-py2.7.egg/crispy_forms/layout.py", line 416, in render fields += render_field(field, form, form_style, context, template_pack=template_pack)

File "/home/sentiers/Geotrek/lib/eggs/django_crispy_forms-1.2.3-py2.7.egg/crispy_forms/utils.py", line 48, in render_field return field.render(form, form_style, context, template_pack=template_pack)

File "/home/sentiers/Geotrek/lib/eggs/django_crispy_forms-1.2.3-py2.7.egg/crispy_forms/layout.py", line 416, in render fields += render_field(field, form, form_style, context, template_pack=template_pack)

File "/home/sentiers/Geotrek/lib/eggs/django_crispy_forms-1.2.3-py2.7.egg/crispy_forms/utils.py", line 126, in render_field html = template.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 140, in render return self._render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 134, in _render return self.nodelist.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 840, in render bit = self.render_node(node, context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 854, in render_node return node.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/defaulttags.py", line 305, in render return nodelist.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 840, in render bit = self.render_node(node, context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 854, in render_node return node.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/defaulttags.py", line 305, in render return nodelist.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 840, in render bit = self.render_node(node, context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 854, in render_node return node.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/defaulttags.py", line 305, in render return nodelist.render(context)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/template/base.py", line 843, in render bits.append(force_text(bit))

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/utils/encoding.py", line 100, in force_text s = s.unicode()

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/forms/forms.py", line 425, in str return self.as_widget()

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/forms/forms.py", line 475, in as_widget return widget.render(name, self.value(), attrs=attrs)

File "/home/sentiers/Geotrek/geotrek/core/widgets.py", line 72, in render return super(BaseTopologyWidget, self).render(name, value, attrs)

File "/home/sentiers/Geotrek/lib/eggs/mapentity-1.8.4-py2.7.egg/mapentity/widgets.py", line 17, in render return super(MapWidget, self).render(name, value, attrs)

File "/home/sentiers/Geotrek/lib/eggs/django_leaflet-0.14.1-py2.7.egg/leaflet/forms/widgets.py", line 56, in render return super(LeafletWidget, self).render(name, value, attrs)

File "/home/sentiers/Geotrek/lib/eggs/Django-1.6.5-py2.7.egg/django/contrib/gis/forms/widgets.py", line 72, in render serialized=self.serialize(value),

File "/home/sentiers/Geotrek/geotrek/core/widgets.py", line 54, in serialize return value.serialize() if value else ''

File "/home/sentiers/Geotrek/geotrek/core/models.py", line 307, in serialize return TopologyHelper.serialize(self, **kwargs)

File "/home/sentiers/Geotrek/geotrek/core/helpers.py", line 170, in serialize point = topology.geom.transform(settings.API_SRID, clone=True)

AttributeError: 'NoneType' object has no attribute 'transform'

<WSGIRequest path:/intervention/edit/208/, GET:<QueryDict: {}>, POST:<QueryDict: {}>, COOKIES:{'csrftoken': 'xVc2XMKVsjR1qjJqoP9g6nlf5i9WpVzU', 'sessionid': 'ya2n47u1qkew4lf759ruqo01xzqrdp72'}, META:{u'CSRF_COOKIE': u'xVc2XMKVsjR1qjJqoP9g6nlf5i9WpVzU', 'HTTPACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,/_;q=0.8', 'HTTP_ACCEPT_ENCODING': 'gzip, deflate', 'HTTP_ACCEPT_LANGUAGE': 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3', 'HTTP_CONNECTION': 'close', 'HTTP_COOKIE': 'csrftoken=xVc2XMKVsjR1qjJqoP9g6nlf5i9WpVzU; sessionid=ya2n47u1qkew4lf759ruqo01xzqrdp72', 'HTTP_HOST': '87.98.XXX.XXX', 'HTTP_REFERER': 'http://87.98.XXX.XXX/intervention/208/', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0', 'HTTP_X_FORWARDED_FOR': '194.51.227.14', 'HTTP_X_FORWARDED_HOST': '87.98.XXX.XXX', 'HTTP_X_FORWARDED_SERVER': '87.98.XXX.XXX', 'PATH_INFO': u'/intervention/edit/208/', 'QUERY_STRING': '', 'RAW_URI': '/intervention/edit/208/', 'REMOTE_ADDR': '194.51.227.14', 'REMOTE_PORT': '80', 'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': u'', 'SERVER_NAME': '87.98.145.147', 'SERVER_PORT': '80', 'SERVER_PROTOCOL': 'HTTP/1.0', 'SERVER_SOFTWARE': 'gunicorn/0.17.4', 'gunicorn.socket': <socket._socketobject object at 0x119ec670>, 'wsgi.errors': <open file '', mode 'w' at 0x7f22608a9270>, 'wsgi.file_wrapper': <class gunicorn.http.wsgi.FileWrapper at 0x313fef0>, 'wsgi.input': <gunicorn.http.body.Body object at 0x11a54e10>, 'wsgi.multiprocess': True, 'wsgi.multithread': False, 'wsgi.run_once': False, 'wsgi.url_scheme': 'http', 'wsgi.version': (1, 0)}>

leplatrem commented 10 years ago

The two errors are different, please open a distinct issues on django-mapentity for the second one. (If you refer this issue in the description there, they both will appear as linked)

leplatrem commented 10 years ago

The first error is due to an empty topology. It has no paths ! Thus it has a NULL geom, thus it fails at loading in the form...

~/Geotrek$ bin/django shell
Python 2.7.3 (default, Feb 27 2014, 19:58:35) 
>>> from geotrek.maintenance.models import Intervention
>>> i = Intervention.objects.get(pk=208)
>>> i.geom
>>> i.topology.geom
>>> i.topology.kind
u'INTERVENTION'
>>> i.topology.paths.all()
[]
>>> i.topology.id
923470
>>> 

I repaired it by adding a random path. But we should investigate how this could happen! Can you check if you have other topologies (e_t_evenement) with empty geom, that are not deleted please ? Thanks !

camillemonchicourt commented 10 years ago

OK I removed the second error from this issue and added an issue in Django-mapentity : https://github.com/makinacorpus/django-mapentity/issues/104

Thanks for repairing the INTERVENTION without PATH. Sadly users couldnt tell me how it happened...

I will check if there are some others.

camillemonchicourt commented 10 years ago

OK so "SELECT * FROM e_t_evenement WHERE geom ISNULL" returns 34 lines

image

But these are all deleted events. They all have a geom_3D (sometimes with 0 as value).