From 9d2e1f065ede189f65e79eb3cb33a33b460a4351 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Wed, 17 Oct 2012 11:55:38 +0200 Subject: [PATCH] Reported OpenLayersWidget exceptions through logging --- django/contrib/gis/admin/widgets.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/django/contrib/gis/admin/widgets.py b/django/contrib/gis/admin/widgets.py index 47570d3f9da..f4379be7f31 100644 --- a/django/contrib/gis/admin/widgets.py +++ b/django/contrib/gis/admin/widgets.py @@ -1,3 +1,5 @@ +import logging + from django.forms.widgets import Textarea from django.template import loader, Context from django.templatetags.static import static @@ -10,6 +12,8 @@ from django.contrib.gis.geos import GEOSGeometry, GEOSException, fromstr # Creating a template context that contains Django settings # values needed by admin map templates. geo_context = Context({'LANGUAGE_BIDI' : translation.get_language_bidi()}) +logger = logging.getLogger('django.contrib.gis') + class OpenLayersWidget(Textarea): """ @@ -29,7 +33,11 @@ class OpenLayersWidget(Textarea): if isinstance(value, six.string_types): try: value = GEOSGeometry(value) - except (GEOSException, ValueError): + except (GEOSException, ValueError) as err: + logger.error( + "Error creating geometry from value '%s' (%s)" % ( + value, err) + ) value = None if value and value.geom_type.upper() != self.geom_type: @@ -56,7 +64,11 @@ class OpenLayersWidget(Textarea): ogr = value.ogr ogr.transform(srid) wkt = ogr.wkt - except OGRException: + except OGRException as err: + logger.error( + "Error transforming geometry from srid '%s' to srid '%s' (%s)" % ( + value.srid, srid, err) + ) wkt = '' else: wkt = value.wkt