There is documentation on using Python dict with z3c.form (loading & storing form data).
However, the z3c.form datamanager used for dicts is not registered for other types or interfaces (see reference), whereas annotations typically use something like PersistentDict.
How can I use the DictionaryField datamanager in this scenario? Ie. so that in my form's getContent method I merely return the PersistentDictannotation.
Well, unfortunately there seems no simple solution for this requirement. I once faced the same problem using the datagrid field in a z3c form.
The following instruction solves the problem for the datagrid field, which is a
list(PersistentList ofdicts(PersistentMappings).I guess you may adapt this solution for your case.
First you need to add the following code to the
getContentmethod:Important note: I wrap the annotation storage to satisfy the get/set behavior of the z3c form. Check the following
YourStorageConfigimplementation and you will see why :-).yourfieldnameshould be the field name you are using in the form schema.To implement the a datagrid field, there is some more work to do, but this may be enough for your case.
Please post comments, or tracebacks, so I can provide further help. I'll gonna add more details/explanation if necessary ;-)