Changes between Initial Version and Version 1 of Ticket #28105


Ignore:
Timestamp:
04/21/17 00:12:04 (7 years ago)
Author:
Tim Graham
Comment:

Could you explain more about the use case that causes the crash? If you could write a test for tests/gis_tests/test_geoforms.py, that would be ideal.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #28105

    • Property Severity changed from Normal to Release blocker
    • Property Triage Stage changed from Unreviewed to Accepted
    • Property Component changed from Forms to GIS
    • Property Summary changed from Missing check in django.contrib.forms.widgets to BaseGeometryWidget.get_context() crashes if attrs contains the name of an existing key
  • Ticket #28105 – Description

    initial v1  
    1 In django.contrib.forms.widgets there is this part (line 67 in corrent master):
     1In`contrib.gis.forms.widgets` there is this part (line 67 in current master):
    22
     3{{{
    34context = self.build_attrs(self.attrs, dict(
    4             name=name,
    5             module='geodjango_%s' % name.replace('-', '_'),  # JS-safe
    6             serialized=self.serialize(value),
    7             geom_type=gdal.OGRGeomType(self.attrs['geom_type']),
    8             STATIC_URL=settings.STATIC_URL,
    9             LANGUAGE_BIDI=translation.get_language_bidi(),
    10             **attrs
    11         ))
     5    name=name,
     6    module='geodjango_%s' % name.replace('-', '_'),  # JS-safe
     7    serialized=self.serialize(value),
     8    geom_type=gdal.OGRGeomType(self.attrs['geom_type']),
     9    STATIC_URL=settings.STATIC_URL,
     10    LANGUAGE_BIDI=translation.get_language_bidi(),
     11    **attrs
     12))
     13}}}
    1214
    1315If `attrs` also contains a key 'geom_type' this leads to an inevitable crash.
     
    1517This should probaly be something like:
    1618
     19{{{
    1720context_kwargs = attrs.copy()
    18 context_kwargs.upgrade(dict(
    19             name=name,
    20             module='geodjango_%s' % name.replace('-', '_'),  # JS-safe
    21             serialized=self.serialize(value),
    22             geom_type=gdal.OGRGeomType(self.attrs['geom_type']),
    23             STATIC_URL=settings.STATIC_URL,
    24             LANGUAGE_BIDI=translation.get_language_bidi(),
     21context_kwargs.update(dict(
     22    name=name,
     23    module='geodjango_%s' % name.replace('-', '_'),  # JS-safe
     24    serialized=self.serialize(value),
     25    geom_type=gdal.OGRGeomType(self.attrs['geom_type']),
     26    STATIC_URL=settings.STATIC_URL,
     27    LANGUAGE_BIDI=translation.get_language_bidi(),
    2528))
    26 
     29}}}
    2730Currently this causes django-bootstrap3 to fail for Django 1.11.
Back to Top