It would be great for cherrypy to handle this condition as
just a
nonexistent session.
My reason for this testing is to just make it bulletproof.
We'll be
installing this app on machines at law firms, where net
access to this
data from the outside is forbidden, and even physically
impossible. If
a client has this problem, I will not be able to fix it for
them. So I
must prove that cherrypy is "idiot-proof" to get
it approved as the web
framework of choice for the application I am designing.
If cherrypy cannot recover from a lost session file, it will
look
unstable to the client, and to the law firms's system
admins, who are
wondering why such a seemingly simple problem causes a
failure. It's
not about proper use. It's about improper use, and
anticipating the
uninformed user/admin who may inadvertently clean up
everything they do
not understand.
Actually, I found with my test program that it only hangs if
I do an
internal redirect after removing the session file.
The test files:
default.conf
[global]
server.socket_port = 1111
server.thread_pool = 10
tools.sessions.on = True
tools.sessions.storage_type = "file"
tools.sessions.storage_path = "./SessionData"
tools.sessions.timeout = 60
[/static]
tools.staticdir.on = True
tools.staticdir.dir =
"/usr/local/http/2.0.59/htdocs_ssl"
session_test.py:
import cherrypy
TemplatePath='./Templates'
class Login:
def index(self):
dbname = cherrypy.session['session_data'] =
"test"
ft=open(TemplatePath + '/login')
showPage=ft.read()
ft.close()
return showPage
index.exposed = True
def login_resp(self):
try:
sdata =
cherrypy.session.get('session_data')
if not sdata:
raise
cherrypy.InternalRedirect(TemplatePath + '/')
#return "No session
file!"
except (TypeError,KeyError,IndexError):
raise
cherrypy.InternalRedirect(TemplatePath +
'/')
#return "No session data!"
+
Handy.get_a_traceback()
return "Found session data: %s" %
sdata
login_resp.exposed = True
if __name__ == '__main__':
cherrypy.tree.mount(Login())
import os.path
cherrypy.config.update(os.path.join(os.path.dirname(__file__
),
'default.conf'))
cherrypy.server.quickstart()
cherrypy.engine.start()
Templates/login:
<center>
<h3>Just click this button:</h3>
<form action="login_resp"
method="post">
<br><input type="submit"
value="Login"/>
</form>
</center>
SessionData/* starts out empty
To reproduce:
Run session_test.py , click on the html button to create a
session
file.
Remove the session file, and refresh the output page. Notice
that it
hangs.
Kill it, and uncomment out the return statements, comment
out the raise
cherrypy.Internalredirect() statements.
Rerun session_data.py. Notice that it no longer hangs.
Is there something wrong with my InternalRedirect syntax?
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
-~----------~----~----~----~------~----~------~--~---
|