[Twisted-web] Newbie help on session data
Craig H. Anderson
craig at coot.net
Thu Jun 10 18:07:26 MDT 2004
I am working on an internal database app
served by twisted.web. I need help on
how to attach data to sessions. Point
me to any examples to look at. Here is
fragments from my first nonworking attempt.
#-------------------------
from twisted.python import components
from twisted.web.resource import Resource
class IGcsSession(components.Interface):
def getData(self):
"""Return the session data
"""
class GcsSession:
__implements__ = (IGcsSession, )
def __init__(self):
self.counter = 0
self.dict = {}
def getData(self):
return self
class CalForm(Resource):
template render(self,request):
sess = request.getSession()
sessData = sess.getComponent(IGcsSession,default=GcsSession())
sessData.counter += 1
resource = CalForm()
More information about the Twisted-web
mailing list