Hi all:
I am having an issue with persisting session data. I am attempting to store a
simple string HTTP_REFERER in to a session variable in the __before__ method
of my base controller, like so:
class BaseController(WSGIController):
def __call__(self, environ, start_response):
"""Invoke the Controller"""
. . .standard stuff in here. . .
Session.remove()
def __before__(self):
environ = request.environ
if 'REMOTE_USER' not in environ:
session['HTTP_SEC_REF'] = environ.get('HTTP_REFERER')
session.save()
self.start_response('401 Not signed in', [])
I can see the data/cookies are created in my beaker cache dirs
(./data/sessions/) but I cannot access it in the controller that validates
the sign-n request:
class AuthController(BaseController):
def __before__(self):
# override the secure base controller method/recursion
pass
def signin(self, message = None):
if message is not None:
c.message = message
else:
c.message = 'Please Sign In'
c.content = """
<html>
<body>
<form action="/auth/v_signin">
Username: <input type="text" name="username" />
Password: <input type="password" name="password" />
<br />
<input type="submit" value="Sign in" />
</body>
</html>
"""
return render('/auth.mako')
def v_signin(self):
# Quick and dirty sign in check, do it properly in your code
environ = request.environ
params = {}
for part in environ['QUERY_STRING'].split('&'):
params[part.split("=")[0]] = part.split('=')[1]
self.start_response('200 OK', [('Content-type', 'text/html')])
if params['username'] and params['password']:
# . . .signin stuff here
if 'HTTP_SEC_REF' in session:
c.message = "Signed in." + ' ' + session['HTTP_SEC_REF']
else:
c.message = "signed in., no session key"
#redirect_to(session['HTTP_SEC_REF'])
return render('/auth.mako')
except:
return self.signin('Login failed')
else:
self.signin('Invalid username and/or password')
It has got to be something downright stupid that I am (or am not) doing. Any
help is much appreciated. The app:main of test.ini follows:
[app:main]
use = egg:wftest
full_stack = true
cache_dir = %(here)s/data
beaker.session.key = wftest
beaker.session.secret = j4AcGzBWIBFTGnIB2l6R9pAGa
app_instance_uuid = {7b9e1b5c-935a-4f1e-beba-494ab48b8ebe}
# Specify the database for SQLAlchemy to use.
# %(here) may include a ':' character on Windows environments; this can
# invalidate the URI when specifying a SQLite db via path name
sqlalchemy.url = postgres://XXXXXXXX:[EMAIL PROTECTED]:5434/wftest
# If you'd like to fine-tune the individual locations of the cache data dirs
# for the Cache data, or the Session saves, un-comment the desired settings
# here:
beaker.cache.data_dir = %(here)s/data/cache
beaker.session.data_dir = %(here)s/data/sessions
# WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
# Debug mode will enable the interactive debugging tool, allowing ANYONE to
# execute malicious code after an exception is raised.
#set debug = false
#RLR added for postgres auth
authkit.enable = true
authkit.setup.method = forward, cookie
authkit.cookie.secret = asdfasdf
authkit.forward.internalpath = /auth/signin
authkit.cookie.signoutpath = /auth/signout
A few hours down the drain on this. . .simple issue. Thanks again.
Richard
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---