2 messages in com.googlegroups.pylons-discussRe: Controller class instance
FromSent OnAttachments
csog...@public.gmane.org21 Feb 2007 20:12 
Robert Leftwich21 Feb 2007 20:25 
Subject:Re: Controller class instance
From:Robert Leftwich (pylo@public.gmane.org)
Date:02/21/2007 08:25:42 PM
List:com.googlegroups.pylons-discuss

csog@public.gmane.org wrote:

I would like to find out of a controller class instance is created only once for each session, even though it's called multiple times. Based on my tests it seems that my global data (self.myvar) disappears every time its controller is referenced by a different controller of the same login session.

Controllers will be created for each request. Assuming the the 'self' referred to above is a controller then self.myvar will definitely disappear. If you want to see a detailed analysis of what happens on a request then see http://sluggo.scrapping.cc/python/pylons/pylons-execution.html

What I'm trying to do is cache some intensive SQL-generated data so it doesn't fetch them every time the controller is called.

Pylons has specific support for that use case - see http://pylonshq.com/docs/0.9.4.1/caching.html

Robert