On Tue, Jan 16, 2007 at 08:19:24PM +0200, Alex Shteinberg wrote...... > Yes right on both counts, it works 10x > >> I have tried to update my working cp2 code and failed. > >> a not working version of the cp3 code
[30/Jan/2007:11:38:30] HTTP Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/cherrypy/_cprequest.py", line 340, in respond self.hooks.run('before_handler') File "/usr/lib/python2.4/site-packages/cherrypy/_cprequest.py", line 76, in run hook() File "/usr/lib/python2.4/site-packages/cherrypy/_cprequest.py", line 44, in __call__ return self.callback(**self.kwargs) File "/usr/lib/python2.4/site-packages/cherrypy/_cptools.py", line 138, in _wrapper if self.callable(**kwargs): File "/usr/lib/python2.4/site-packages/cherrypy/lib/cptools.py", line 278, in session_auth return sa.run() File "/usr/lib/python2.4/site-packages/cherrypy/lib/cptools.py", line 271, in run return self.do_check() File "/usr/lib/python2.4/site-packages/cherrypy/lib/cptools.py", line 246, in do_check sess = cherrypy.session AttributeError: 'module' object has no attribute 'session'
> [30/Jan/2007:11:38:30] HTTP Traceback (most recent call last): > File > "/usr/lib/python2.4/site-packages/cherrypy/_cprequest.py", > line 340, in respond > self.hooks.run('before_handler') > File > "/usr/lib/python2.4/site-packages/cherrypy/_cprequest.py", > line 76, in run > hook() > File > "/usr/lib/python2.4/site-packages/cherrypy/_cprequest.py", > line 44, in __call__ > return self.callback(**self.kwargs) > File > "/usr/lib/python2.4/site-packages/cherrypy/_cptools.py", line > 138, in _wrapper > if self.callable(**kwargs): > File > "/usr/lib/python2.4/site-packages/cherrypy/lib/cptools.py", > line 278, in session_auth > return sa.run() > File > "/usr/lib/python2.4/site-packages/cherrypy/lib/cptools.py", > line 271, in run > return self.do_check() > File > "/usr/lib/python2.4/site-packages/cherrypy/lib/cptools.py", > line 246, in do_check > sess = cherrypy.session > AttributeError: 'module' object has no attribute 'session'
> Any idea what I'm missing?
Because sessions are an extension to CherryPy (and not a builtin), there will be no "cehrrypy.session" object unless you either 1) turn on tools.sessions, or 2) do it yourself by calling lib.sessions.init and friends.
Robert Brewer System Architect Amor Ministries fuman...@amor.org
On Tue, Jan 30, 2007 at 09:17:13AM -0800, Robert Brewer wrote...... > Because sessions are an extension to CherryPy (and not a builtin), > there will be no "cehrrypy.session" object unless you either 1) > turn on tools.sessions, or 2) do it yourself by calling > lib.sessions.init and friends.
Thanks. That did the trick. For those like me who have struggled with some of these things, below you will find a working code example for CP 3.0:
----- import cherrypy
def loadUserByUsername(login): ulist=[("user1","pass1"),("user2","pass2")] for u,p in ulist: if u==login: return (u,p)
def checkLoginAndPassword(login, password): user = loadUserByUsername(login) if user==None: return u'Wrong login/password'