Save dictionary containing data in ZODB

I am trying to take user input in a form and save it.
I have created the form.
The data is in the dictionary called data in the action handler.
Now how to save the data in ZODB?

If the data to be stored is defined as a schema of your current context object then you can use

context.some_attr = value


setattr(context, 'some_attr', value)

If you need to store arbitrary data that is not defined in any way through a schema, use annotation storage


souper.plone integrates souper with Plone

souper.plone helps developers who need to store many small data records, where heavy-weight Archetypes or Dexterity content types are too much effort and are too slow. E.g. if you need a queryable container for non-CMSish content, like votes, data from a poll, orders in a webshop, measuring data, or the like.

A Soup-container can be moved to an own ZODB mount-point and may be shared across multiple independent Plone instances!

A control-panel provides actions to rebuild, reindex and move Soups around.

Slighly off topic, but often it is possible to use Formgen ( or collective.easyform) without having to program anything. For example Formgen has adapters to save data, add content, mail input etc.

1 Like