[Django] #27557: Overzealous GEOSGeometry sub-subclasses casts

20 views
Skip to first unread message

Django

unread,
Nov 30, 2016, 5:46:08 AM11/30/16
to django-...@googlegroups.com
#27557: Overzealous GEOSGeometry sub-subclasses casts
----------------------------------------+------------------------
Reporter: Claude Paroz | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: master
Severity: Normal | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+------------------------
Reported by Pete Flugstad in
https://groups.google.com/forum/#!topic/geodjango/-tao0uPNYY8

When writing a Point, Polygon, etc. subclass, the parent
`GEOSGeometry._post_init` is force casting the instance to one of the
hardcoded GEOSGeometry subclass, which breaks method overriding of the
subclass.

Example:
{{{
from django.contrib.gis.geos import Polygon

class ExtendedPolygon(Polygon):
def __init__(self, point_list, data=0 ):
super(ExtendedPolygon, self).__init__(point_list)
self._data = data

def __str__(self):
return "EXT_POLYGON - data: %d - %s" % (self._data, self.wkt )
}}}

{{{
>>> from extpoly import ExtendedPolygon
>>> points = ((-75.1, 34.3), (-74.9, 34.3), (-74.9, 34.4), (-75.1, 34.4),
(-75.1, 34.3))
>>> ex = ExtendedPolygon( points, altitude=123, speed=456, direction=789 )
>>> print(ex)
POLYGON ((-75.09999999999999 34.3, -74.90000000000001 34.3,
-74.90000000000001 34.4, -75.09999999999999 34.4, -75.09999999999999
34.3))
>>> type(ex)
<class 'django.contrib.gis.geos.polygon.Polygon'>
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27557>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 30, 2016, 6:36:28 AM11/30/16
to django-...@googlegroups.com
#27557: Overzealous GEOSGeometry sub-subclasses casts
------------------------------+------------------------------------

Reporter: Claude Paroz | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by Claude Paroz):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/7640 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/27557#comment:1>

Django

unread,
Nov 30, 2016, 10:43:17 AM11/30/16
to django-...@googlegroups.com
#27557: Overzealous GEOSGeometry sub-subclasses casts
-------------------------------------+-------------------------------------

Reporter: Claude Paroz | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/27557#comment:2>

Django

unread,
Nov 30, 2016, 11:53:00 AM11/30/16
to django-...@googlegroups.com
#27557: Overzealous GEOSGeometry sub-subclasses casts
-------------------------------------+-------------------------------------

Reporter: Claude Paroz | Owner: nobody
Type: Bug | Status: closed
Component: GIS | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz <claude@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"cc9e4297019bcec9fe0fee2199aa30fb1f6e90b7" cc9e4297]:
{{{
#!CommitTicketReference repository=""
revision="cc9e4297019bcec9fe0fee2199aa30fb1f6e90b7"
Fixed #27557 -- Casted GEOSGeometry only when necessary

Thanks Pete Flugstad for the report, and Tim Graham for the review.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27557#comment:3>

Reply all
Reply to author
Forward
0 new messages