Hi there,
here's another problem I encountered when porting my webapp from TG
1.0 to TG
1.1. Given a form with schemas (stripped down excerpt below):
class RegistrationForm(ListForm):
class RegistrationFields(WidgetsList):
class PersonalDetailsFields(WidgetsList):
lastname = TextField(label=_(u"Last name"))
firstname = TextField(label=_(u"First name"))
personal = FieldSet(
legend = _(u"Personal information"),
fields = PersonalDetailsFields())
class RegistrationSchema(Schema):
class PersonalDetailsSchema(Schema):
lastname = UnicodeString(strip=True, not_empty=True,
max=20)
firstname = UnicodeString(strip=True, not_empty=True,
max=20)
personal = PersonalDetailsSchema()
fields = RegistrationFields()
validator = RegistrationSchema()
This worked pretty fine with the validate-decorator in 1.0. Now with
1.1 I
always get validate-errors for the schema named
"PersonalDetailsSchema" as
there is no such sub-form (the only given sub-form is given by the key
'personal'). Actually the real name would be "personal", like the name
of the
form above. The @validate-decorator seems to validate the instance of
the
PersonalDetailsSchema-class as well as the class itself.
If I clear out the schema-class by setting PersonalDetailsSchema=None
after the instantiation of 'personal' like this:
class RegistrationSchema(Schema):
class PersonalDetailsSchema(Schema):
lastname = UnicodeString(strip=True, not_empty=True, max=20)
firstname = UnicodeString(strip=True, not_empty=True, max=20)
personal = PersonalDetailsSchema()
PersonalDetailsSchema = None
validation works well. I can as well move the RegistrationSchema-class
out of the
RegistrationForm-class to module level, which also works. The problem
is that
both ways somehow feel wrong to me. And moreover, I have lots of huge
formsets
in my app, which would require a lot of changes.
What am I missing here? Is this a FormEncode-issue? What's the
"offcial" way
to define forms with nested schemas in TG 1.1?
Thank you!
Daniel
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---