Raja
unread,Mar 3, 2008, 3:50:19 AM3/3/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to cherrypy-devel
Hi all,
I face aproblem in cherrypy.
Following is my code.
import cherrypy
import os
from cherrypy.lib import static
class root:
def index( self ):
return '''
<HTML>
<BODY>
<FORM name=login_page action="/GreetUser/" enctype="multipart/
form-data" method="POST">
<TABLE bgcolor=lightsteelblue align=center >
<TR>
<TD colspan=2 align=middle><INPUT type="submit" value="Login"
onclick=login_page.submit() ></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>'''
index.exposed = True
def GreetUser( self ):
return '''
<HTML>
<BODY>
WELCOME...
</HTML>
</BODY>'''
GreetUser.exposed = True
rt = root()
cherrypy.tree.mount(rt)
if __name__ == '__main__':
cherrypy.config.update(os.path.join(os.path.dirname(__file__),
'tutorial.conf'))
current_dir = os.path.dirname(os.path.abspath(__file__))
cherrypy.config.update({'environment': 'production',
'log.error_file': 'site.log',
'log.screen': True})
cherrypy.server.quickstart()
cherrypy.engine.start()
-----------------------------------------------------------------------------------------------------------------------------------------
If u want to run this code, please create a "tutorial.conf" file in
the same directory from where u run the code.
In the "tutorial.conf" file add the following contents, save it and
then run the code.
[global]
server.socket_port = 80
server.thread_pool = 10
tools.sessions.on = True
-----------------------------------------------------------------------------------------------------------------------------------------
Now, if you keep a breakpoint in "GreetUser" function and click the
login button in your browser,
you can find the "GreetUser" function being called twice. So if I want
to update database fields in this function it would be updated twice
which would lead to a crash of Application.
I don't know why it is happening...
I think I am not making any mistakes in code... am I???
Could you please tell me a solution for this?????
Regards,
Raja