Max Ischenko wrote:
> Geoffrey Talvola wrote:
>> Yes, that is definitely a problem. You are using class variables
>> instead of instance variables. Class variables are shared among all
>> instances, and this would explain why you are seeing the data shared
>> across sessions. Put your initialization into the __init__ instead.
>> In other words, instead of:
>> class Cart:
>> customer = Customer()
>> You should use:
>> class Cart:
>> def __init__(self):
>> self.customer = Customer()
> Isn't the instance variable problematic as well (to a lesser degree)?
> AFAIK, WebKit shares servlet instances, so it's quite possible that
> the same Cart() instance could be used to process requests from the
> different (user) sessions?
> Correct me if I'm wrong, please.
First of all, Cart isn't a servlet, so the lifecycle of servlets isn't
But anyhow, Servlet instances are _recycled_. Once a servlet instance is
done processing a request, it will be reused for a future request. This is
why you need to use awake() and sleep() instead of __init__() and __del__()
for per request initialization and finalization -- because __init__ is only
called once, and __del__ normally isn't called at all, until the appserver
> But anyhow, Servlet instances are _recycled_. Once a servlet instance is
> done processing a request, it will be reused for a future request.
> - Geoff
Isn't this only true if you've set CacheServletInstances to a non zero
value? It may be a quibbling point, but if you set this value to 0, it
shouldn't be recycling servlet instances anymore, right?
Its possible I misunderstand the meaning behind that configuration value,
but thats the meaning I've been assuming. Depending upon how heavy your
traffic is or how large your servlet classes are some people might not be
switching that value to non zero in a production version of their
Admittedly, this doesn't in any way detract the from the rest of what you
said. I just wanted to get clarification on servlet recycling and
Get latest updates about Open Source Projects, Conferences and News.