Combine different Schema classes together
Andrea Riciputi <[email protected]> Thu, 5 Mar 2009 17:50:05 +0100
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I have a form composed of several fieldsets. Since I need to re-use
those fieldsets over and over again in many forms, I thought to write
a Schema object for each fieldset, and then combine them in a super-
validator. Something like this:
class Foo(Schema):
allow_extra_fields = True
filter_extra_fields = True
... foo validators here ...
pass
class Bar(Schema):
allow_extra_fields = True
filter_extra_fields = True
... bar validators here ...
pass
class Gnus(Schema):
allow_extra_fields = True
filter_extra_fields = True
... gnus validators here ...
pass
class SuperSchema(Foo, Bar, Gnus):
pass
But when I try to validate the super-form using SuperSchema I can get
only fields defined in Foo, whilst the others are stripped. On the
other hand defining SuperSchema like this:
class SuperSchema(Foo, Bar, Gnus):
allow_extra_fields = True
filter_extra_fields = False
pass
works correctly, but leave me without protection from malicious fields
sent by the clients. Is there any other way to make this to work
correctly without disabling the extra fields filter?
Cheers,
Andrea
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H