Better handling of a POSKeyError?

I am polishing up the 2017.ploneconf.org site so that I can use httrack on it to generate a static copy, to be served instead of the Plone site.

When I rebuild the catalog, I get a POSKeyError, which I tracked down to the page https://2017.ploneconf.org/talks/talks. If you scroll down to the end of the keynotes and before the normal talks list, you can see that a tile renders with There was an error while rendering this tile

Looking with the wayback machine, that tile is a simple decorative one: https://web.archive.org/web/20171001014802/https://2017.ploneconf.org/talks/talks

The POSKeyError prevents edits to the page, with the error stack:

Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module plone.z3cform.layout, line 66, in __call__
  Module plone.z3cform.layout, line 60, in update
  Module z3c.form.form, line 162, in render
  Module zope.browserpage.viewpagetemplatefile, line 51, in __call__
  Module zope.pagetemplate.pagetemplate, line 132, in pt_render
  Module five.pt.engine, line 98, in __call__
  Module z3c.pt.pagetemplate, line 163, in render
  Module chameleon.zpt.template, line 261, in render
  Module chameleon.template, line 171, in render
  Module e849b7e41dd33f6ab4d1c8ff87f943e6.py, line 91, in render
  Module 5620a03a37d3f1a6291e1271c97b8981.py, line 1806, in render_titlelessform
  Module 5620a03a37d3f1a6291e1271c97b8981.py, line 451, in render_fields
  Module 5620a03a37d3f1a6291e1271c97b8981.py, line 126, in render_widget_rendering
  Module 5620a03a37d3f1a6291e1271c97b8981.py, line 1069, in render_field
  Module five.pt.expressions, line 161, in __call__
  Module Products.Five.browser.metaconfigure, line 485, in __call__
  Module zope.browserpage.viewpagetemplatefile, line 83, in __call__
  Module zope.browserpage.viewpagetemplatefile, line 51, in __call__
  Module zope.pagetemplate.pagetemplate, line 132, in pt_render
  Module five.pt.engine, line 98, in __call__
  Module z3c.pt.pagetemplate, line 163, in render
  Module chameleon.zpt.template, line 261, in render
  Module chameleon.template, line 191, in render
  Module chameleon.template, line 171, in render
  Module 74dbae3624aadc951e477c8552a3d8f5.py, line 591, in render
  Module 74dbae3624aadc951e477c8552a3d8f5.py, line 466, in render_widget_wrapper
  Module five.pt.expressions, line 161, in __call__
  Module plone.app.z3cform.widget, line 578, in render
  Module plone.app.z3cform.widget, line 548, in _base_args
  Module plone.app.textfield.value, line 65, in raw_encoded
  Module ZODB.Connection, line 860, in setstate
  Module ZODB.Connection, line 901, in _setstate
  Module ZEO.ClientStorage, line 833, in load
  Module ZEO.ServerStub, line 176, in loadEx
  Module ZEO.zrpc.connection, line 768, in call
POSKeyError: 0x059954

 - Expression: "widget/@@ploneform-render-widget"
 - Filename:   ... rm-1.2.3-py2.7.egg/plone/app/z3cform/templates/macros.pt
 - Location:   (line 98: col 81)
 - Source:     ... place="structure widget/@@ploneform-render-widget"/>
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 - Expression: "widget/render"
 - Filename:   ... rm-1.2.3-py2.7.egg/plone/app/z3cform/templates/widget.pt
 - Location:   (line 38: col 46)
 - Source:     ... xt" tal:replace="structure widget/render"
                                              ^^^^^^^^^^^^^
 - Arguments:  repeat: {...} (0)
               context: <RichTextWidget IRichText.text at 0x7fc51eeb9710>
               views: <ViewMapper - at 0x7fc51fd7abd0>
               modules: <TraversableModuleImporter - at 0x7fc53ddf5a50>
               args: <tuple - at 0x7fc54575c050>
               nothing: <NoneType - at 0x91a870>
               target_language: <NoneType - at 0x91a870>
               default: <object - at 0x7fc545679530>
               request: <instance - at 0x7fc51df56ab8>
               wrapped_repeat: {...} (0)
               loop: {...} (0)
               template: <ViewPageTemplateFile - at 0x7fc525492990>
               translate: <function translate at 0x7fc52488bed8>
               options: {...} (0)
               view: <RenderWidget ploneform-render-widget at 0x7fc51fd7ae50>

I tried to mess with /usr/local/plone-5.0/buildout-cache/eggs/plone.app.textfield-1.2.8-py2.7.egg/plone/app/textfield/value.py https://github.com/plone/plone.app.textfield/blob/1.2.8/plone/app/textfield/value.py#L56 and have it return a simple string if it caught a POSKeyError, but that doesn't seem to work; something above in the call stack may be swallowing the exception:

@property
def raw(self):
	from ZODB.POSException import POSKeyError
    try:
	    return self._raw_holder.value
    except POSKeyError:
        return 'POSKeyError!!!'

I'd like to make it possible to edit the page to delete and recreate that decorative tile, or at least be able to rebuild the catalog.

Help! :slight_smile: Thanks!

If I change

return 'POSKeyError!!!'

to

return None

to better match a calling frame that checks for a None return value:

I get this stack trace instead of carrying on with an empty value:

2019-02-17 17:11:42 ERROR ZODB.Connection Couldn't load state for 0x059954
Traceback (most recent call last):
  File "/usr/local/plone-5.0/buildout-cache/eggs/ZODB3-3.10.7-py2.7-linux-x86_64.egg/ZODB/Connection.py", line 860, in setstate
    self._setstate(obj)
  File "/usr/local/plone-5.0/buildout-cache/eggs/ZODB3-3.10.7-py2.7-linux-x86_64.egg/ZODB/Connection.py", line 901, in _setstate
    p, serial = self._storage.load(obj._p_oid, '')
  File "/usr/local/plone-5.0/buildout-cache/eggs/ZODB3-3.10.7-py2.7-linux-x86_64.egg/ZEO/ClientStorage.py", line 833, in load
    data, tid = self._server.loadEx(oid)
  File "/usr/local/plone-5.0/buildout-cache/eggs/ZODB3-3.10.7-py2.7-linux-x86_64.egg/ZEO/ServerStub.py", line 176, in loadEx
    return self.rpc.call("loadEx", oid)
  File "/usr/local/plone-5.0/buildout-cache/eggs/ZODB3-3.10.7-py2.7-linux-x86_64.egg/ZEO/zrpc/connection.py", line 768, in call
    raise inst # error raised by server
POSKeyError: 0x059954
2019-02-17 17:11:42 ERROR plone.subrequest Error handling subrequest to http://localhost:8082/Ploneconf2017/talks/talks/@@plone.\
app.standardtiles.field?field=IRichText-text
Traceback (most recent call last):
  File "/usr/local/plone-5.0/buildout-cache/eggs/plone.subrequest-1.7.0-py2.7.egg/plone/subrequest/__init__.py", line 153, in su\
brequest
    bind=1
  File "/usr/local/plone-5.0/buildout-cache/eggs/Zope2-2.13.26-py2.7.egg/ZPublisher/mapply.py", line 78, in mapply
    else: return object(*args)
  File "/usr/local/plone-5.0/buildout-cache/eggs/plone.app.standardtiles-1.0-py2.7.egg/plone/app/standardtiles/field.py", line 1\
18, in __call__
    return self._wrap_widget(widget.render())
  File "/usr/local/plone-5.0/buildout-cache/eggs/plone.app.z3cform-1.2.3-py2.7.egg/plone/app/z3cform/widget.py", line 631, in re\
nder
    return self.value.output
  File "/usr/local/plone-5.0/buildout-cache/eggs/plone.app.textfield-1.2.8-py2.7.egg/plone/app/textfield/value.py", line 89, in \
output
    return self.output_relative_to(site)
  File "/usr/local/plone-5.0/buildout-cache/eggs/plone.app.textfield-1.2.8-py2.7.egg/plone/app/textfield/value.py", line 115, in\
 output_relative_to
    return transformer(self, self.outputMimeType)
  File "/usr/local/plone-5.0/buildout-cache/eggs/plone.app.textfield-1.2.8-py2.7.egg/plone/app/textfield/transform.py", line 26,\
 in __call__
    if value.raw is None:
  File "/usr/local/plone-5.0/buildout-cache/eggs/plone.app.textfield-1.2.8-py2.7.egg/plone/app/textfield/value.py", line 57, in \
raw
    from ZODB.POSException import POSKeyError
SystemError: error return without exception set

Plone Foundation Code of Conduct