[PEAK] Object-level validation hook

Phillip J. Eby pje at telecommunity.com
Thu Oct 13 23:33:46 EDT 2005


At 11:52 AM 10/13/2005 -0400, Erik Rose wrote:
>On Jul 27, 2003, at 9:34 PM, in "Re: [TransWarp] Constraints on model
>attributes", Phillip J. Eby wrote:
>
>>Indeed, I wonder if maybe peak.model should offer an object-level
>>validation hook, that gets called before an object's state can be
>>flushed to storage.  If this hook were also callable by UI
>>frameworks, they could simply set all values as desired, call the
>>validation hook to get a list of problems, and roll back the
>>transaction.
>
>Yes, please! :-D

Something like this will be in peak.schema, implemented using a generic 
function.  If you want to create your own, though, just create a generic 
function like 'validate(ob, callback)' and call it from your DMs' _save() 
methods.  The function's methods would call the callback with any errors, 
then call the next method in the chain.  The callback for _save() would 
raise an error, but a UI framework could implement the callback to add the 
errors to a list, then display them later.

Anyway, lots of possibilities, and very easy to just go ahead and implement 
in the meantime if you need/want them.

Heck, generic functions make so many things easy that there's hardly any 
need for anybody to have me write the frameworks any more.  Just use 
generic functions and you don't need any frameworks.  :)




More information about the PEAK mailing list