Skip to content

make form storage retrieval configurable #63

Description

@petri

z3c.form uses adaptation for configurable data managers (IDataManager), to customize writing and reading data to/from the storage (whatever it may be).

However that is only half of what should be be there: we do not have same configurability for fetching the storage itself. Instead, the form getContent implementation is hardcoded to return the context object (using context in the normal Zope/Plone sense here).

This is fine in typical Zope/Plone cases when the editable (context) object attributes are used for storage. But already when storing form data in the context object annotations (with the z3c.form DictionaryField data manager), a custom form with overriden getContent (to return the annotation instead of context object) is required.

Furthermore, what if the form data storage is not the context object or some part of it? Perhaps there is a separate storage, such as one provided by Souper? Or, what if we want to use z3c.form to store data in a SQL database, Apache Kafka, or persist it over the network somewhere?

For such use cases, it would be useful if getContent used a multi-adapter (context, request) to fetch and return the "content (storage) object", (say, IFormStorageProvider), resorting to current behavior if no adapter is found.

I volunteer to provide a PR if this idea is accepted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions