wagtail-deprecated / wagtail-react-streamfield

Powerful field for inserting multiple blocks with nesting. (NO LONGER MAINTAINED - See Wagtail 2.13 Release Notes)
https://wagtail.github.io/react-streamfield/public/
BSD 3-Clause "New" or "Revised" License
74 stars 23 forks source link

Compatibility issue with wagtail-geo-widget #4

Closed rafaponieman closed 6 years ago

rafaponieman commented 6 years ago

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!!

BertrandBordage commented 6 years ago

I partially fixed wagtail-geo-widget compatibility with b8e3cdd2a1310ec83b843c8c46cc040dc5a7d73d. 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.

BertrandBordage commented 6 years ago

Partial fix released in 0.8.3.

BertrandBordage commented 6 years ago

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.