[Zope3-Users] zope.formlib doesn't check invariants on subschemas - need workaround

Stephan Richter srichter at cosmos.phy.tufts.edu
Sun Feb 3 00:24:34 EST 2008

On Saturday 02 February 2008, Derek Richardson wrote:
> After help from Philipp and some investigation, I determined that the
> problem is that schema B isn't itself the main form, but is nested
> within schema A as the value_type of a Tuple field. When schema A is
> validated, schema B's invariant is not checked. I think this may be a
> bug. If someone more knowledgeable will confirm, then I will open a bug
> report.

I would not consider this a bug. I would not expect it to work this way. But 
then I also think that the generic Object field is evil, though I am 
sometimes sucked into believing it is not. So I guess the way to fix it would 
be to check the invariants within the validation method of the Object field.

> In the mean time, I need a workaround that verifies that the invariants
> on all instances of schema B in the Tuple on schema A hold during form
> validation. My nascent idea is to put an invariant on schema A that
> checks all the invariants on all schema B instances. However, I am not
> familiar enough with formlib internals to code this up without
> significant research. Can someone help me out with an implementation for
> this workaround or an idea for a different, better workaround?

Yep, that workaround work, but the error message does not appear in the right 
location. I do not use formlib, so I cannot help with an implementation 

Stephan Richter
Web Software Design, Development and Training
Google me. "Zope Stephan Richter"

More information about the Zope3-users mailing list