Hi I'm trying to update a user row upon the user logging in. I simply want to increase the users login count by one. Here is the code in the post_login controller method:
@expose()
def post_login(self, came_from=url('/')):
"""
Redirect the user to the initially requested page on successful
authentication or redirect her back to the login page if login failed.
"""
if not request.identity:
login_counter = request.environ['repoze.who.logins'] + 1
redirect(url('/user/login', came_from=came_from, __logins=login_counter))
user_name = request.identity['repoze.who.userid']
user = User.by_user_name(user_name)
user.tll_num_logins += 1
user.tll_last_login = datetime.now()
redirect(came_from)
The user record simply isnt getting updated in the database. The TG documentation says that the transaction manager should flush all of the transactions and automatically execute all the outstanding SQL but it doesnt seem to be working with update. I've tried putting in a DBSession.commit() after to manually commit but get an error message. Likewise, adding DBSession.flush() to the controller method does not error but does not actually update the record either.