Author: jbronn Date: 2009-01-07 14:21:19 -0600 (Wed, 07 Jan 2009) New Revision: 9711
Modified: django/trunk/django/contrib/gis/gdal/field.py Log: Return None for null date/time fields in OGR-supported data sources. Thanks to Ariel Mauricio Nunez Gomez for bug report and initial patch. Modified: django/trunk/django/contrib/gis/gdal/field.py =================================================================== --- django/trunk/django/contrib/gis/gdal/field.py 2009-01-06 18:25:52 UTC (rev 9710) +++ django/trunk/django/contrib/gis/gdal/field.py 2009-01-07 20:21:19 UTC (rev 9711) @@ -127,34 +127,34 @@ @property def value(self): "Returns a Python `date` object for the OFTDate field." - yy, mm, dd, hh, mn, ss, tz = self.as_datetime() try: + yy, mm, dd, hh, mn, ss, tz = self.as_datetime() return date(yy.value, mm.value, dd.value) - except ValueError: + except (ValueError, OGRException): return None class OFTDateTime(Field): @property def value(self): "Returns a Python `datetime` object for this OFTDateTime field." - yy, mm, dd, hh, mn, ss, tz = self.as_datetime() # TODO: Adapt timezone information. # See http://lists.maptools.org/pipermail/gdal-dev/2006-February/007990.html # The `tz` variable has values of: 0=unknown, 1=localtime (ambiguous), # 100=GMT, 104=GMT+1, 80=GMT-5, etc. try: + yy, mm, dd, hh, mn, ss, tz = self.as_datetime() return datetime(yy.value, mm.value, dd.value, hh.value, mn.value, ss.value) - except ValueError: + except (ValueError, OGRException): return None class OFTTime(Field): @property def value(self): "Returns a Python `time` object for this OFTTime field." - yy, mm, dd, hh, mn, ss, tz = self.as_datetime() try: + yy, mm, dd, hh, mn, ss, tz = self.as_datetime() return time(hh.value, mn.value, ss.value) - except ValueError: + except (ValueError, OGRException): return None # List fields are also just subclasses --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---