I'm developing a z3c.form based form, which should store it's form values
in the session. To accomplish that, the form needs to retrieve it's values
from the session.
My idea was to simply store the form data in the button handler method
into the session as a dictionary. z3c.form then offers the "getContent()"
method, which would simply retrieve the dictionary from the session.
The problem is, that if the dictionary does not contain all fields, an
error is raised. The reason for this error lies in line 97 in
z3c.form.widget: The value is retrieved via the get() function (which does
a dict.get()) and thus fails.
The solution for this problem would be to replace the datamanager.get() by
datamanager.query(), as this would return the default field value.
However, this may break other projects, therefore I would suggest to:
- Introduce some form option such as "ContextQuery=True/False"
- Either use dm.get() or .query() regarding to this option
What's your opinion on this? Would this be a decent solution?
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9 4902 64B4 D16B 2998 93C7
Zope3-users mailing list