List Info

Thread: Validation and Events




Validation and Events
user name
2006-09-24 16:32:32
Hi,

Is it possible yet to hook in a validator to an Archetypes
object using
Five/Zope3 events?

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).

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
_______________________________________________
Archetypes-devel mailing list
Archetypes-devellists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/archet
ypes-devel
Validation and Events
user name
2006-09-25 17:00:28
George Lee wrote:
> Is it possible yet to hook in a validator to an
Archetypes object using
> Five/Zope3 events?

I don't understand what events have to do with validators.

> 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).

You want zope.interface's invariants.  See 
http://svn.zope.org/Zope3/t
runk/src/zope/interface/README.txt?rev=70082&view=auto


------------------------------------------------------------
-------------
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
_______________________________________________
Archetypes-devel mailing list
Archetypes-devellists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/archet
ypes-devel
Validation and Events
user name
2006-09-25 20:18:36
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
_______________________________________________
Archetypes-devel mailing list
Archetypes-devellists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/archet
ypes-devel
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )