X-No-Archive:yes

Beaker using memory-based sessions works fine for me, but when I
switch to file-based sessions it continues to store session info in
memory (no files appear in the designated data_dir and sessions do not
persist after resetting the server). I have Myghty installed also.
What is going on?

Here is a full working example. Thanks!

from beaker.session import
SessionMiddleware
import
web
from web import
form

log_in =
form.Form(
    form.Textbox("login", form.notnull,
description="Username"),
    form.Password("password",
form.notnull,
 
description="Password")
    )

urls =
(
    '/',
'index',
    '/logout',
'logout',)

users = {"sl":
"123"}

class
index:
    def
GET(self):
        web.header("Content-Type","text/html;
charset=utf-8")
        session =
web.ctx.environ['beaker.session']
        if session.has_key('logeddin') and
session['logeddin']:
            print "U logged as <b>%s</
b>"%session["username"]
 
else:
            print "<form name='main' method='post'> "+ log_in.render()
+ "<input type='submit' />"

    def
POST(self):
        session =
web.ctx.environ['beaker.session']
        i =
web.input()
        if i.login in users and users[i.login] ==
i.password:
            session['logeddin'] =
1
            session['username'] =
i.login
 
session.save()
 
web.seeother("/")

class
logout:
    def
GET(self):
        session =
web.ctx.environ['beaker.session']
 
session.invalidate()
 
web.seeother("/")

def
session_mw(app):
    return SessionMiddleware(app, key = "sid", type="file", data_dir="/
Full/Path/To/Sessions/Directory/")

if __name__ ==
"__main__":
    web.run(urls, globals(), *(web.reloader,
session_mw))

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to