Note: I'm willing to submit a PR on this, if the idea is approved.
We keep running into a problem on re-printing forms-
Our csrf_ field, along with some internal metrics, are essentially handled in another layer of our stack and not known to formencode.
The problem we've run into, is that these fields are obliterated on a form reprint, because formencode will strip the rendered values out -- unless we set 'force_defaults', which offers some utility that we don't want to use.
What I'd like to propose is extending htmill.render and FillingParser with a new boolean argument titled something like ignore_unknown_fields. This way 'force_defaults' could apply to all the actual formencode fields, but it could be disabled for all the extraneous fields.
Here's an example:
If set to True the various checks for force_defaults would be replaced with something like:
-if value is None and not self.force_defaults:
+if value is None and (not self.force_defaults or (self.ignore_unknown_fields and name not in self.errors)):
it would be different for each tag type; the above works because value is already set to be the value from self.defaults[name].
Note: I'm willing to submit a PR on this, if the idea is approved.
We keep running into a problem on re-printing forms-
Our csrf_ field, along with some internal metrics, are essentially handled in another layer of our stack and not known to formencode.
The problem we've run into, is that these fields are obliterated on a form reprint, because formencode will strip the rendered values out -- unless we set 'force_defaults', which offers some utility that we don't want to use.
What I'd like to propose is extending
htmill.renderandFillingParserwith a new boolean argument titled something likeignore_unknown_fields. This way 'force_defaults' could apply to all the actual formencode fields, but it could be disabled for all the extraneous fields.Here's an example:
If set to
Truethe various checks forforce_defaultswould be replaced with something like:it would be different for each tag type; the above works because
valueis already set to be the value from self.defaults[name].