Question

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?

Was it helpful?

Solution

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

OTHER TIPS

plone.app.registry is not really designed to store binary data. It is designed to be simple, lightweight and migration-proof.

What are you trying to achieve with this? There is probably a better way.

Ok, seems that you can have the same behavior also on Plone 3; in only needed an upgrade of plone.z3cform

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top