On 03/06/11 11:41 +0200, Udo Spallek wrote:
> Hi,
> Am Donnerstag, den 02.06.2011, 21:22 +0200 schrieb Cédric Krier:
> > On 02/06/11 19:17 +0000, cedric.kr...@b2ck.com wrote:
> > > Reviewers: ,
> > > Please review this at http://codereview.tryton.org/42001/
> > Thanks to comment also on the design/API.
> 
> Why is it needed to instantiate the Pool every time before use? E.g.:
> 
> pool = Pool()
> action_obj = pool.get('ir.action')
> 
> Since now it is a singleton, why we can not call a class method
> directly? E.g.:
> 
> action_obj = Pool().get('ir.action')

This is the same as above because you instanciate Pool.

I stored in many places the instance of pool just for performance issue.
Because the __new__ method of Pool, that returns the Singleton instance per
database, needs to use locks to prevent threading issues. So I would try to
avoid to call too much this method when it is not needed.

I also though about changint Pool.get into a classmethod which will make the
code looks like:

    action_obj = Pool.get('ir.action')

But this will just the same as calling Pool().get because I will anyway need
to retrieve the database instance of Pool and then I will need to pass
through the locks.

> It would be much less work to rewrite existing module code :-)

I don't think and any cases we must go through all the code :-)

Also, here we have the same behavior than the Transaction object.

-- 
Cédric Krier

B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email/Jabber: cedric.kr...@b2ck.com
Website: http://www.b2ck.com/

Attachment: pgpM3RtWtDj3h.pgp
Description: PGP signature

Reply via email to