SimpleSessionApp, <a href> and session time out
Hans Kramer <[email protected]> Thu, 09 Oct 2008 10:53:26 +0200
| Newsgroups | gmane.comp.web.albatross.general |
|---|---|
| Message-ID | <[email protected]> |
--===============6062631334677894595==
Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-h4eV6WM1a1lsYgWkgzAY"
--=-h4eV6WM1a1lsYgWkgzAY
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
Dear all,
I am new to Albatross and Python Webframe works. Moreover, I am not a
seasoned web developer and in the past I really hated working with this
kind of technology. However, I have to say that I really like what you
guys have done with Albatross. I am excited.
I have a few questions and half baked solutions I want to have some feed
back on.
First of all I would like to use the SimpleSessionApp class
instead of the RandomModularSessionApp class. (I tend to like to work
with classes) Perhaps this is a mistake, just be frank.
A)
Then I want to have a link in my template files for people to log out.
Something like this: (I also need these kind of links for other
purposes, I might come on in a later e-mail)
<al-a href=3D"logout">Log Out</al-a>
Clicking on it, the frame work should execute:
class LogoutPage:
name =3D 'logout'
def page_process(self, context):
context.remove_session()
context.set_page('login')
Currently that didn't work. I found a solution by making some small
changes. First I edited in app.py the run method of class Application.
Just before self.load_page(ctx) I put the following command:
if os.environ.has_key('PATH_INFO'):=20
ctx.locals.__page__ =3D os.environ['PATH_INFO'][1:]
This works fine, except that in the next page the URI is rendered as
/cgi-bin/application.py/logout and the user cannot log in. I fixed this
by editing cgiapp.py and changing
def get_uri(self):
return self.get_param('REQUEST_URI')
to
def get_uri(self):
return self.get_param('SCRIPT_NAME')
Is this going to break anything? Is this a good solution? Or am I doing
something fundamentally wrong (by for instance using SimpleSessionApp).
If not, can I supply a patch?
B)
Session time out that was something that was biting me too. I work for a
Pharmaceutical company (clinical trail) and they really hate to see
stack traces. So when a session times out, instead of the stack trace I
want to refer it to a TimeOut page. (in the future I might want to
implement something that browser keeps refreshing the session as long as
it is alive... anybody?).
I solved that in similar fashion as above. However, due to lack of the
understanding of the internals I hard coded the page name timeout.
Again I edited run method in app.py. If the load_session fails, I create
a new session and send if off to the timeout page.
try:
self.load_session(ctx)
if os.environ.has_key('PATH_INFO'):
ctx.locals.__page__ =3D os.environ['PATH_INFO'][1:]
except:
ctx.new_session()
ctx.locals.__page__ =3D "timeout"
Please let me know what anybody thinks of the edits I made.
Thanks again for creating such a new framework.=20
Kind regards,
Hans Kramer
--=-h4eV6WM1a1lsYgWkgzAY
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQBI7caGwGRENV8Xlu8RApnFAJ0Tla7PcuvZAvcakG7g/+Zt+4wb2QCdEaGT
ahyXiKGFLxqE9m+LuydSN3w=
=xOwv
-----END PGP SIGNATURE-----
--=-h4eV6WM1a1lsYgWkgzAY--
--===============6062631334677894595==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Albatross-users mailing list
[email protected]
https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users
--===============6062631334677894595==--