#2393: Forms with nested schemas
-------------------------------+--------------------------------------------
Reporter: guest | Owner: Chris Arndt
Type: defect | Status: assigned
Priority: normal | Milestone: __unclassified__
Component: TG Widgets | Version: 1.1
Severity: normal | Resolution:
Keywords: forms, FormEncode |
-------------------------------+--------------------------------------------
Changes (by Chris Arndt):
* status: new => assigned
Comment:
I did some research on this issue. It seems that the way you define your
nested validators was never supported by !FormEncode directly. If you
define a validator class inside of another, the class will be added to the
list of nested validators under the class name.
It was only possible in !TurboGears to work around this because
`turbogears.validators.Schema` sets the `if_key_missing` attribute to
`None`, so when FE validates the data, it will just assign a `None` value
to those fields, i.e. you get `PersonalDetailsFields=None` in the data
with your example above.
Why this isn't working anymore in FE > 0.7.1 I don't know. I think you
should raise this issue on the FormEncode mailing list.
It seems to me that you were relying on an undocumented behaviour of
!TurboGears/!FormEncode, which is long gone. Since it works if you define
the nested validators outside of the parent validator class, I guess you
just have to change your form definitions.
Alternatively, you should be able to just name your nested validator
classes so that they match the names of the nested forms, e.g.:
{{{
class PersonSchema(Schema):
class namefields(Schema):
firstname = UnicodeString(...)
...
...
}}}
'''BUT''' unfortunately, `turbogears.widgets.meta.add_field_to_schema`
chokes on
this, because it uses `isinstance` to check the nested validators. This
should be fixed to also test using `issubclass` (needs fixes to
`copy_schema` as well).
I attached my test script so you can experiment yourself.
To sum it up:
* You fix your nested validator definitions.
* We fix `add_field_to_schema`.
--
Ticket URL: <http://trac.turbogears.org/ticket/2393#comment:3>
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
-~----------~----~----~----~------~----~------~--~---