#28105: BaseGeometryWidget.get_context() crashes if attrs contains the name of 
an
existing key
-------------------------------------+------------------------------------
     Reporter:  Dylan Verheul        |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  GIS                  |                  Version:  1.11
     Severity:  Release blocker      |               Resolution:
     Keywords:  gis, forms, widgets  |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+------------------------------------
Changes (by Tim Graham):

 * severity:  Normal => Release blocker
 * stage:  Unreviewed => Accepted
 * component:  Forms => GIS


Old description:

> In django.contrib.forms.widgets there is this part (line 67 in corrent
> master):
>
> context = self.build_attrs(self.attrs, dict(
>             name=name,
>             module='geodjango_%s' % name.replace('-', '_'),  # JS-safe
>             serialized=self.serialize(value),
>             geom_type=gdal.OGRGeomType(self.attrs['geom_type']),
>             STATIC_URL=settings.STATIC_URL,
>             LANGUAGE_BIDI=translation.get_language_bidi(),
>             **attrs
>         ))
>
> If `attrs` also contains a key 'geom_type' this leads to an inevitable
> crash.
>
> This should probaly be something like:
>
> context_kwargs = attrs.copy()
> context_kwargs.upgrade(dict(
>             name=name,
>             module='geodjango_%s' % name.replace('-', '_'),  # JS-safe
>             serialized=self.serialize(value),
>             geom_type=gdal.OGRGeomType(self.attrs['geom_type']),
>             STATIC_URL=settings.STATIC_URL,
>             LANGUAGE_BIDI=translation.get_language_bidi(),
> ))
>
> Currently this causes django-bootstrap3 to fail for Django 1.11.

New description:

 In`contrib.gis.forms.widgets` there is this part (line 67 in current
 master):

 {{{
 context = self.build_attrs(self.attrs, dict(
     name=name,
     module='geodjango_%s' % name.replace('-', '_'),  # JS-safe
     serialized=self.serialize(value),
     geom_type=gdal.OGRGeomType(self.attrs['geom_type']),
     STATIC_URL=settings.STATIC_URL,
     LANGUAGE_BIDI=translation.get_language_bidi(),
     **attrs
 ))
 }}}

 If `attrs` also contains a key 'geom_type' this leads to an inevitable
 crash.

 This should probaly be something like:

 {{{
 context_kwargs = attrs.copy()
 context_kwargs.update(dict(
     name=name,
     module='geodjango_%s' % name.replace('-', '_'),  # JS-safe
     serialized=self.serialize(value),
     geom_type=gdal.OGRGeomType(self.attrs['geom_type']),
     STATIC_URL=settings.STATIC_URL,
     LANGUAGE_BIDI=translation.get_language_bidi(),
 ))
 }}}
 Currently this causes django-bootstrap3 to fail for Django 1.11.

--

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.

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/062.933449a58522941d0d8d484d18f946dc%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to