I need to store inside plone.app.registry binary data in a way compatible from Plone 3.3 to 4.2.
Using simply a schema.Byte
type I'm able to quickly reach this on Plone 4.2 (not very user friendly, but it works), but not on Plone 3.3.
On Plone 3.3 the registry is displyaing a file upload control, but when I try to get the saved data I found that it simply stored a string like:
'<... HTTPFileUpload...>'
...so a python repr of an object.
How can I fix this? I need to use plone.namedfile product with collective.z3cform.filewidget?
Since plone.formwidget.namedfile 1.0.12 you can use that wigets on ASCII fields also. Data is then converted to base64. Plone 5 uses that feature for it's site logo, which is stored in the registry.
For an example, see the Plone 4 backport of that feature: https://github.com/collective/collective.sitelogo
Especially:
Usage of an ASCII
field for your image: https://github.com/collective/collective.sitelogo/blob/master/src/collective/sitelogo/interfaces.py#L14
Changing the controlpanel widget for the ASCII
field to NamedImageFieldWidget
: https://github.com/collective/collective.sitelogo/blob/master/src/collective/sitelogo/controlpanel.py#L19