Andrea Riciputi
2009-03-05 16:50:05 UTC
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
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