Renaming fields using a Schema

"Ed Singleton" <[email protected]>
Newsgroups gmane.comp.web.turbogears,gmane.comp.python.formencode
Message-ID <[email protected]>
I'm using a FormEncode Schema to validate a dictionary, and I was
wondering if it would be easy to get the validator to rename fields on
the way through?

Something like:

data = {'email': '[email protected]'}

class MyValidator(validators.Schema):
    email = validators.Email(not_empty=True, new_field_name='user_email')

my_validator = MyValidator()

valid_data = my_validator.to_python(data)

print valid_data

## {'user_email': '[email protected]'}

Thanks

Ed

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.