Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Reported OpenLayersWidget exceptions through logging

  • Loading branch information...
commit 9d2e1f065ede189f65e79eb3cb33a33b460a4351 1 parent fd02bcf
@claudep claudep authored
Showing with 14 additions and 2 deletions.
  1. +14 −2 django/contrib/gis/admin/widgets.py
View
16 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 @@
# 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 @@ def render(self, name, value, attrs=None):
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 @@ def render(self, name, value, attrs=None):
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

0 comments on commit 9d2e1f0

Please sign in to comment.
Something went wrong with that request. Please try again.