Hi again,
I have another problem unrelated to my previous post.
Here's my code:
import cherrypy
import pdb
TemplatePath='./Templates'
class Login:
def index(self):
ft=open(TemplatePath + '/login')
showPage=ft.read()
ft.close()
return showPage
index.exposed = True
def login_resp(self,username,password):
return "Login: Got parameters: %s
%s" %
(username,password)
login_resp.exposed = True
class Login2:
def index(self,username,password):
return "Login2: Got parameters: %s
%s" %
(username,password)
index.exposed = True
if __name__ == '__main__':
root = Login()
root.login_resp2 = Login2()
cherrypy.tree.mount(root)
import os.path
cherrypy.config.update(os.path.join(os.path.dirname(__file__
),
'default.conf'))
cherrypy.server.quickstart()
cherrypy.engine.start()
Here is the HTML used to access these methods:
<center>
<h3>Please log in:</h3>
<form action="login_resp"
method="post">
<br>Username
<input type="text"
name="username" value=""
size="15" maxlength="40"/>
<br>Password
<input type="password"
name="password" value=""
size="10" maxlength="40"/>
<br><input type="submit"
value="Login"/>
<br><input type="reset"
value="Clear"/>
</form>
</center>
The things I'm testing are login_resp, and login_resp2.
Notice the
nesting, and how login_resp class, Login(), is what root is
intialized
to use. login_resp2 is a separate class, initialized as
root.login_resp2.
In my FORM, my action is set to login_resp, and things work
fine:
Login: Got parameters: test hkjkh
If I then change my FORM action to login_resp2, refresh,
and send the
exact same parameters, I get this:
Traceback (most recent call last):
File
"/usr/local/python/2.5/lib/python2.5/site-packages/cher
rypy/_cprequest.py",
line 539, in respond
cherrypy.response.body = self.handler()
File
"/usr/local/python/2.5/lib/python2.5/site-packages/cher
rypy/_cprequest.py",
line 110, in __call__
return self.callable(*self.args, **self.kwargs)
TypeError: index() takes exactly 3 arguments (1 given)
The correct method in the correct class is being called, but
the
parameters from the FORM are not being passed into the
root.login_resp2 class. Why is this happening?
Thank you,
Gloria
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at ht
tp://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|