Changes between Initial Version and Version 1 of Ticket #28105


Ignore:
Timestamp:
Apr 20, 2017, 7:12:04 PM (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 Component FormsGIS
    • Property Severity NormalRelease blocker
    • Property Triage Stage UnreviewedAccepted
    • Property Summary Missing check in django.contrib.forms.widgetsBaseGeometryWidget.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