def changeUserPassword(user,password): mySession = DBSession() try: transaction.begin() mySession.query(User).filter_by(user_name = user).update({"user_password": encodeData(password)}) transaction.commit() mySession.close() return True except: transaction.abort() mySession.close() return False
def addUser(userData): mySession = DBSession() newUser = User(userData["user_name"],userData["user_fullname"],encodeData(userData["user_password"]),userData["user_organization"],userData["user_email"], str(uuid.uuid4()),userData["user_cnty"],userData["user_sector"],"") try: transaction.begin() mySession.add(newUser) #Add the ne user to MySQL transaction.commit() mySession.close() return True,"" except Exception, e: transaction.abort() mySession.close() return False,str(e)