This one has me stumped. Can anyone see the problem. It bombs on this
line:

db.update('users', uvar, where = 'uid = $uid', lastlog =
"datetime('now')")

[code]
    def POST(self):
        import re, base64
        auth = web.ctx.env.get('HTTP_AUTHORIZATION')
        authreq = False
        if auth is None:
            authreq = True
        else:
            auth = re.sub('^Basic ','',auth)
            uid, pwd = base64.decodestring(auth).split(':')
            uvar = dict(uid=uid,
pwd=unicode(base64.encodestring(pwd).rstrip()))
            chk = db.select('users', uvar, where = 'uid = $uid and pwd
= $pwd')[0]
            if not chk:
                authreq = True
            else:
                session.uid = uid
                session.email = chk.email
                #log login
                #db.update("update users set lastlog=datetime('now')
where uid=$uid", vars={'uid':uid})
                db.update('users', uvar, where = 'uid = $uid', lastlog
= "datetime('now')")
                raise web.seeother('/')

        if authreq:
            web.header('WWW-Authenticate','Basic realm="login"')
            web.ctx.status = '401 Unauthorized'
            return
[/code]


Local vars:
auth
'Z3Jhc3N5OnBhc3N3b3Jk'
authreq
False
base64
<module 'base64' from '/usr/lib/python2.7/base64.pyc'>
chk
<Storage {'lastlog': u'2011-04-23 08:57:59', 'pwd': u'cGFzc3dvcmQ=',
'email': u'[email protected]', 'joined': u'2011-04-22 23:36:27',
'uid': u'grassy'}>
pwd
'password'
re
<module 're' from '/usr/lib/python2.7/re.pyc'>
self
<admin.Login instance at 0x2bb1b48>
uid
'grassy'
uvar
{'pwd': u'cGFzc3dvcmQ=', 'uid': 'grassy'}

-- 
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