#2393: Forms with nested schemas
------------------------+---------------------------------------------------
 Reporter:  guest       |       Owner:                   
     Type:  defect      |      Status:  new              
 Priority:  normal      |   Milestone:  __unclassified__ 
Component:  TurboGears  |     Version:  1.1              
 Severity:  normal      |    Keywords:  forms, FormEncode
------------------------+---------------------------------------------------
 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 TG 1.0.8 using
 FormEncode 0.7.1. Now with 1.1 (and FormEncode 1.2.2) 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
 }}}

 then validation works well. I can as well move the
 `RegistrationSchema`-class
 out of the `RegistrationForm`-class to module level, which also works.

 I attached a minimal testcase below.

 Discussion:
 http://groups.google.com/group/turbogears/browse_thread/thread/79d703a064f7f69f

-- 
Ticket URL: <http://trac.turbogears.org/ticket/2393>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "TurboGears Tickets" group.
This group is read-only. No posting by normal members allowed.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to