← Back to team overview

openerp-expert-framework team mailing list archive

Re: _constraints message improvement

 

On 07/08/2011 12:09 AM, Albert Cervera i Areny wrote:
> Well, we use an osv.except_osv() instead of returning False.

That works as a valid alternative, good point!


> I think the API should simply not include the possibility of adding a
> static text and force the developer to always use the exception. The
> possibility that comments Olivier seems to complex to me, compared to
> how easy it is to raise an insightful exception.

_constraints offer a SQL-like way to perform business-level validation
checks. Hence the API is based on the result of a boolean test, exactly
like SQL constraints, and the user notification is handled elsewhere. To
me, this is good and simple, and you have the other, more complicated
options when needed (such as explicitly raising).

The static messages also save you the trouble of repeated boilerplate
code (raising, translating, coming up with a yet another meaningful
exception title, etc.), for the many cases where a static message is
sufficient.


Follow ups

References