Re: [SQLObject] caching an expensive property

2014-12-10 Thread Oleg Broytman
Hi! On Thu, Dec 11, 2014 at 12:34:35AM +0100, "Fetchinson ." wrote: > Hi Oleg, thanks again, this pushed me in the right direction and found > > http://code.activestate.com/recipes/302997/ Very interesting but overly complex for my taste. > I'm not very good with SQL or > SQLObject in part

Re: [SQLObject] caching an expensive property

2014-12-10 Thread Fetchinson .
On 12/10/14, Oleg Broytman wrote: > On Wed, Dec 10, 2014 at 01:09:50AM +0100, "Fetchinson ." > wrote: >> On 12/10/14, Oleg Broytman wrote: >> > you'd better implement your own >> > caching with proper locking. >> >> Well, that was exactly the question, how would I do that? :) >> Precisely for th

Re: [SQLObject] caching an expensive property

2014-12-10 Thread Oleg Broytman
Hi! On Wed, Dec 10, 2014 at 12:33:03AM +, Daniel Monteiro Basso wrote: > For recent Python versions (>2.7 I guess), you could have also written like: > with self.__cache_lock: > do_stuff > return self.__cache > The context protocol takes care of the rest. Yes, in 2.6+. > Cheers,

Re: [SQLObject] caching an expensive property

2014-12-09 Thread Fetchinson .
On 12/10/14, Oleg Broytman wrote: > On Wed, Dec 10, 2014 at 01:09:50AM +0100, "Fetchinson ." > wrote: >> On 12/10/14, Oleg Broytman wrote: >> > you'd better implement your own >> > caching with proper locking. >> >> Well, that was exactly the question, how would I do that? :) >> Precisely for th

Re: [SQLObject] caching an expensive property

2014-12-09 Thread Daniel Monteiro Basso
For recent Python versions (>2.7 I guess), you could have also written like: with self.__cache_lock: do_stuff return self.__cache The context protocol takes care of the rest. Cheers, Daniel -- Download BIRT iHub F-

Re: [SQLObject] caching an expensive property

2014-12-09 Thread Oleg Broytman
On Wed, Dec 10, 2014 at 01:09:50AM +0100, "Fetchinson ." wrote: > On 12/10/14, Oleg Broytman wrote: > > you'd better implement your own > > caching with proper locking. > > Well, that was exactly the question, how would I do that? :) > Precisely for the reason you mention above I was wary of us

Re: [SQLObject] caching an expensive property

2014-12-09 Thread Fetchinson .
On 12/10/14, Oleg Broytman wrote: > Hi! > > On Wed, Dec 10, 2014 at 12:47:17AM +0100, "Fetchinson ." > wrote: >> What's the best strategy for some kind of caching of an expensive >> property? >> >> Let's say I have the following: >> >> class obj( SQLObject ): >> somefield = StringCol( ) >>

Re: [SQLObject] caching an expensive property

2014-12-09 Thread Oleg Broytman
Hi! On Wed, Dec 10, 2014 at 12:47:17AM +0100, "Fetchinson ." wrote: > What's the best strategy for some kind of caching of an expensive property? > > Let's say I have the following: > > class obj( SQLObject ): > somefield = StringCol( ) > someotherfield = StringCol( ) > > def _get