[Twisted-web] newbiew question
arun chhetri
chhetriarun84 at gmail.com
Tue Jul 22 18:47:24 EDT 2008
from twisted.web import resource, server
from twisted.web import http
class HomePage(resource.Resource):
def __init__(self):
resource.Resource.__init__(self)
self.putChild('calendar',Calendar(user=3DNone,pswd=3DNone,server=3D=
None))
def render(self,request):
return"""<html><body>
<a href =3D calendar>Here is the solution
<body>
</html>"""
def getChild(self,path,request):
return
Calendar(request.args["user"],request.args["pswd"],request.args["server"])
class Calendar(resource.Resource):
def __init__(self,user,pswd,server):
resource.Resource.__init__(self)
self.user =3D user
self.pswd =3D pswd
self.server =3D server
self.putChild('month',Month(user))
def render(self,request):
return"""<p> The user is %s
<a href=3D/calendar/month> The link to the month is this
"""%self.user[0]
def getChild(self,path,request):
return Month(self.user[0])
class Month(resource.Resource):
def __init__(self,user):
resource.Resource.__init__(self)
self.user =3D user
def render(self,request):
return """ %s"""%self.user
if __name__=3D=3D"__main__":
from twisted.internet import reactor
root =3D HomePage()
site =3D server.Site(root)
reactor.listenTCP(8000,site)
reactor.run()
now if i go to http://localhost:8000/?user=3Darun&pswd=3Dtest&server=3Dtest
i get this The user is arun The link to the month is
this<http://localhost:8000/calendar/month>
and if I click the link then I get None
Can anybody help me how I can redirect the value self.user to Month so that
instead of None it shows the user name provided in query string
Thanks in advance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-web/attachments/20080722/c7=
aac222/attachment.htm
More information about the Twisted-web
mailing list