OK, I couldn't resist looking into this -- my curiosity was killing
me. The last time I investigated why pickling class instances wasn't
working, it looked like the fact that we were exec'ing our servlets instead
of importing them was confusing pickle. But we recently switched (in
Webware CVS) from exec'ing servlets to importing servlets as modules in a
package. So I thought, maybe we are now able to pickle class objects in
sessions...
So I wrote a simple test servlet, and it works! I can shut down and
restart my app server and everything works fine and the sessions are
preserved. I've included my test servlet -- a variation of the CountVisits
example that stores the count in a simple class.
So Brad, you could consider switching to a CVS version of Webware. The
current tip of CVS seems quite stable to me.
It's possible that there are problems with more complex cases, but this at
least shows that it's possible to store class instances in sessions.
# PickleTest.py
from WebKit.Page import Page
class Counter:
def __init__(self):
self._count = 0
def incrementCount(self):
self._count = self._count + 1
def count(self):
return self._count
class PickleTest(Page):
def writeContent(self):
counter = self.session().value('counter', None)
if counter is None:
counter = Counter()
self.session().setValue('counter', counter)
counter.incrementCount()
count = counter.count()
if count>1:
plural = 's'
else:
plural = ''
self.writeln("<p> You've been here %d time%s." % (count,
plural))
self.writeln('<p> Try hitting RELOAD now.')
--
- Geoff Talvola
[EMAIL PROTECTED]
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/webware-discuss