Lets say, you have this simple form:

class EditForm(ListForm):
    validator = Schema(
        chained_validators = [FieldsMatch('edit.password',
'edit.password_confirm')]
    )

    def __init__(self, id=None, parent=None, children=[], user=None,
**kw):
        super(EditForm, self).__init__(id, parent, children, **kw)
        fieldset = ListFieldSet("edit", self, legend=_("User data"),
label_text = "",
            children = [
                Child(PasswordField, "password",
label_text=_("Password"), default=getattr(user, "password", None),
validator=UnicodeString(min=1, max=255)),
                Child(PasswordField, "password_confirm",
label_text=_("Password (confirm)"), default=getattr(user, "password",
None), validator=UnicodeString(min=1, max=255)),
            ]
        )

The FildsMatch validator will fail, because there is no key
"edit.password".
A KeyError will be raised in
formencode.validators.FieldsMatch.validate_python as the correct value
is in field_dict["edit"]["password"] and not in
field_dict["edit.password"].

You could circumvent this by adding this line at the beginning of
validate_python:
field_dict =
formencode.variabledecode.variable_encode(field_dict)

For a similar problem (with no answers yet) and a similar solution
see: 
http://groups.google.com/group/turbogears/browse_thread/thread/76b93b0641989e7
Probably there are even more spots in TG/TW that cause troubles with
nested field values tranlated to nested dicts.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to