I have a customer exporter for Plone 4.3 (based on collective.exportimport) that throws the following
warning for content items:
2023-09-15 10:02:02 ERROR collective.exportimport.export_content Error exporting http://nohost/magazine/segnalazioni/unibocultura/tutto-il-verde-intorno-a-noi
Traceback (most recent call last):
File "/home/ajung/src/unibo/eggs/collective.exportimport-1.9-py2.7.egg/collective/exportimport/export_content.py", line 311, in export_content
item = serializer()
File "/home/ajung/src/unibo/eggs/plone.restapi-7.8.2-py2.7.egg/plone/restapi/serializer/dxcontent.py", line 98, in __call__
value = serializer()
File "/home/ajung/src/unibo/eggs/collective.exportimport-1.9-py2.7.egg/collective/exportimport/serializer.py", line 165, in __call__
return json_compatible(value)
File "/home/ajung/src/unibo/eggs/plone.restapi-7.8.2-py2.7.egg/plone/restapi/serializer/converters.py", line 72, in json_compatible
return IJsonCompatible(value, None)
File "/home/ajung/src/unibo/eggs/zope.component-3.9.5-py2.7.egg/zope/component/hooks.py", line 104, in adapter_hook
return siteinfo.adapter_hook(interface, object, name, default)
File "/home/ajung/src/unibo/eggs/plone.restapi-7.8.2-py2.7.egg/plone/restapi/serializer/converters.py", line 105, in list_converter
return list(map(json_compatible, value))
File "/home/ajung/src/unibo/eggs/plone.restapi-7.8.2-py2.7.egg/plone/restapi/serializer/converters.py", line 72, in json_compatible
return IJsonCompatible(value, None)
File "/home/ajung/src/unibo/eggs/zope.component-3.9.5-py2.7.egg/zope/component/hooks.py", line 104, in adapter_hook
return siteinfo.adapter_hook(interface, object, name, default)
File "/home/ajung/src/unibo/eggs/plone.restapi-7.8.2-py2.7.egg/plone/restapi/serializer/converters.py", line 86, in default_converter
" {0!r} ({1}) JSON compatible.".format(value, type(value))
TypeError: No converter for making <SottoeventoUnibocultura Visite guidate all'Orto Botanico ed Erbario> (<class 'unibo.cultura.contents.sottoevento.SottoeventoUnibocultura'>) JSON compatible.
So I added the following adapter to my export script
@adapter(SottoeventoUnibocultura)
@implementer(IJsonCompatible)
def sottoevento_converter(value):
print("x"*800)
import pdb; pdb.set_trace()
if value is None:
return value
However, the registration seems to be ignored (the warning stays the same).
Is there anything missing here? Wild guess: the code registration must happen after calling the setSite()
hook?