← Back to team overview

openerp-community team mailing list archive

Re: Reason to deprecate check_recursion() ?

 

Hello Lionel,

Pylint and Openobject have different conventions about protected 
methods.

For Pylint, a method with a name starting with a single '_' is 
protected, meaning you should only call it from with the class or a 
class deriving from it, e.g. self._method() . Any call to obj._method() 
(with obj != self) will trigger a warning.

For OpenERP, a method with a name starting with a single '_' is not 
exported to the public RPC API, but it still can be called on the 
server side from within the class, and it is common to see code from 
stock.picking calling 'protected' methods from stock.move for instance. 
Such method do not have to adhere to the publicly exported method 
prototype (the cr, uid, .... context=None stanza).

So to make a long story short, it is OK to call _check_recursion in 
your Models and Pylint is wrong.

Alexandre

On lun. 31 mars 2014 14:57:31 CEST, Lionel Sausin wrote:
> Dear Olivier,
> In v7 I just noticed that check_recursion() is deprecated in favor of
> _check_recursion().
> That makes it a protected method, so by convention it should only be
> used inside osv.orm shouldn't it?
> Would you please be kind enough to explain the reason for this and if
> it's OK to call _check_recursion() in our own "Model"s?
> I'm asking because now pylint is looking down on me for using a
> protected method - I just want to make I'm doing it right.
> Lionel.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~openerp-community
> Post to     : openerp-community@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~openerp-community
> More help   : https://help.launchpad.net/ListHelp



--
Alexandre Fayolle
Chef de Projet
Tel : + 33 (0)4 79 26 57 94

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac Cedex
http://www.camptocamp.com



References