Re: Validation and Events
George Lee <[email protected]> Mon, 25 Sep 2006 20:27:33 +0000 (UTC)
| Newsgroups | gmane.comp.web.zope.plone.archetypes.devel |
|---|---|
| Message-ID | <[email protected]> |
> George Lee <georgeleejr@...> writes: > > > Is it possible yet to hook in a validator to an Archetypes object using > > Five/Zope3 events? > > > > 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). > > You want zope.interface's invariants. See > http://svn.zope.org/Zope3/trunk/src/zope/interface/README.txt?rev=70082&view=auto The thought was maybe there was an event that fired up upon validation through base_edit and process_form, that would allow one to add some more work to the validation process of a product without touching its code. With Plone 2.5 and Zope 2.9.4, I've been able to do most of the adding fields and schema to an existing Archetypes product without touching the original product's code, using Five -- but I haven't been able to figure out how to add validation machinery. It looks like I may have to suck it up and just change the original product's validation methods. > 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. That's too bad ... in this case I'm adding a "Deadline Date" and "Deadline Text" field to multiple content types, but want to valdiate that either neither is entered or both are entered. It seems like allowing some of this multiple-field validation would be key down the road to the work to use schemas by interface or otherwise generalize Schema(). Are there any plans to build Zope3 invariants into the Archetypes machinery? Peace, George ------------------------------------------------------------------------- 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