wagtail-deprecated / wagtail-react-streamfield

Powerful field for inserting multiple blocks with nesting. (NO LONGER MAINTAINED - See Wagtail 2.13 Release Notes)

Home Page:https://wagtail.github.io/react-streamfield/public/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compatibility issue with wagtail-geo-widget

rafaponieman opened this issue · comments

This may be a problem in wagtail-geo-widget and not in wagtail-react-streamfield, however I'm reporting it in case it is the latter.

When using a GeoBlock, I'm getting an error on page load:

  File "(...)/wagtail_react_streamfield/widgets.py", line 120, in get_definition
    block.to_python(None), prefix='field-__ID__')
  File "(...)/wagtailgeowidget/blocks.py", line 53, in to_python
    value = geosgeometry_str_to_struct(value)
  File "(...)/wagtailgeowidget/helpers.py", line 18, in geosgeometry_str_to_struct
    result = geos_ptrn.match(value)
TypeError: expected string or bytes-like object

Versions:
Latest wagtail-react-streamfield (79606df), Wagtail 2.2.1, Python 3.6.5.

Thank you!!

I partially fixed wagtail-geo-widget compatibility with b8e3cdd.
Now, going to a page with a GeoBlock works. However, a 'NoneType' object is not subscriptable is yield when saving two times a GeoBlock.
It has to do with the clean method that’s being called when it shouldn’t, but I didn’t figure out yet what was wrong with my code, especially since every other block type now works.

I should be able to fix it, but maybe the cleanest solution in the end will be a change to wagtail-geo-widget to add the value_from_datadict method and folks.

Partial fix released in 0.8.3.

After some digging, I have to set this as a “won’t fix”.

Now that the Python part is correctly handled, there are still some value loading issues, because the library didn’t correctly implement the required internal API methods value_for_form and value_from_form.

The new StreamField renders widget templates only once per block type, thus decreasing dramatically the server response time. So we rely on value_for_form to set widget value after cloning the empty widget template, while the current StreamField relies mostly on render_form that itself relies on value_for_form.

Apart from value_for_form, that module contains some hacks to link an external address block with the coordinates block. These hacks will either have to be updated, or replaced with a cleaner solution.

I’m not happy with that conclusion, but it’s not possible to support all hacks of undocumented behaviours.