A Diumenge, 11 de març de 2012 11:40:54, Cédric Krier va escriure:
> On 11/03/12 11:30 +0100, Albert Cervera i Areny wrote:
> > A Dissabte, 10 de març de 2012 14:52:07, Cédric Krier va escriure:
> > > On 10/03/12 13:08 +0100, Albert Cervera i Areny wrote:
> > > I agree, it is an idea in the pipeline since sometimes.
> > > But I think it should be changed globaly.
> > 
> > Why should it be changed globally. If we said that properties can be
> > changed one at a time, I don't see why we can't commit checks that raise
> > exceptions while existing ones still return False.
> 
> Here are my reasons:
> 
>     - The base code of Tryton must be an example of good practices for
>       developpers.
>     - It is a good way to ensure that every constraints is reviewed and
>       improved.
>     - The documentation must reflect the practice.
> 
> About properties, my thoughts were to have an example. But once there is
> one working example, we should migrate every Models and remove
> properties for the same reasons as above.

Alright. What should the new API look like? I think we should simply convert 
self._constraints from a list of tuples to a list of strings:

self._constraints += [
    'check_one_thing',
    'check_another thing',
    ]

Then, those functions should just raise a user exception with the information 
of the offending record.

At the same time, I think we should remove all exclamation marks from 
exception messages, those are not good from a usability POV. We should not 
scare or shout at users but simply tell them what is wrong with the data they 
provided.

-- 
Albert Cervera i Areny
http://www.NaN-tic.com
Tel: +34 93 553 18 03

http://twitter.com/albertnan 
http://www.nan-tic.com/blog

-- 
[email protected] mailing list

Reply via email to