On 16 May 20:39, Cédric Krier wrote:
> On 16 May 14:20, Udo Spallek wrote:
> > Hi, 
> > 
> > in [1][2] we introduce a ``get_singleton()`` method for Singelton
> > models.
> > In the modules we always use a patter like this::
> > 
> >     Config = pool.get('xxx.configuration')
> >     config = Config(1)
> > 
> > or 
> > 
> >     Configuration = pool.get('xxx.configuration')
> >     config = Configuration(1)
> > 
> > 
> > instead of::
> > 
> >     config = Config.get_singleton()
> > 
> > Is the use of ``get_singleton()`` recommended in module code or better
> > stay with config = Config(1)?
> 
> Obviously it is not the recommended way.
> Indeed I don't see any advantage in using get_singleton but I see one
> for the current way, it prevent a search if the configuration is not
> used.

And I forget that get_singleton can return None if no one was yet
created. So it will make the code more complex.

-- 
Cédric Krier - B2CK SPRL
Email/Jabber: [email protected]
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Attachment: pgpTk4hFGArRL.pgp
Description: PGP signature

Reply via email to