Re: Validation and Events

Martin Aspeli <[email protected]> Mon, 25 Sep 2006 21:18:36 +0100
Newsgroups gmane.comp.web.zope.plone.archetypes.devel
Message-ID <[email protected]>
George Lee wrote:
> Hi,
> 
> Is it possible yet to hook in a validator to an Archetypes object using
> Five/Zope3 events?

That's not so easy - you can easily make some kind of checks based on an 
event, but you'd need a way to signal back that there was some kind of 
validation error. I'm not aware of any framework component that works 
this way at the moment. It may be an interesting design pattern to 
explore, though.

> Related to Martin Aspeli's work on schema-by-interface -- it's clear how that
> could be used to add in a validator just for one new field, but not how we could
> validate that the data from two fields satisfy some condition (e.g., min < max).

mmm... basically, the schema-by-interface work (which will be achieved 
using ContentFlavors - the changes to AT are minimal) it will be just as 
if you'd monkey patched or hand-edited the schema of some class. AT 
validators etc will work as they do now.

If you want to add validators that are not field-specific (e.g. via 
validate_foo() method) then I don't think that's quite in scope.

As Philipp points out, Z3 has its own validation/constraints framework 
which is possibly more appropriate, I haven't really played with it.

Martin


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV