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
relevant here...

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
shuts down.

- Geoff


-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to