I had someone beta-test the website today and they ran into an internal server error when trying to return to the index/show portfolio of stocks screen. The error was this:
File "/home/ubuntu/pset8/finance/application.py", line 68, in index stock_info["total"] = stock_info["shares"] * stock_info["price"] TypeError: unsupported operand type(s) for *: 'NoneType' and 'float' This is the section of the code I think the problem is in, but when querying the database, I'm getting (correct) values.
if stock_symbols != []: stocks = [] for symbol in stock_symbols: symbol_data = lookup(symbol["symbol"]) stock_shares = db.execute("SELECT SUM(shares) FROM portfolio WHERE user_id=:user_id AND symbol=:symbol;", user_id=session["user_id"], symbol=symbol_data["symbol"]) if stock_shares[0]["SUM(shares)"] == 0: continue else: stock_info = {} stock_info["name"] = symbol_data["name"] stock_info["symbol"] = symbol_data["symbol"] stock_info["price"] = symbol_data["price"] stock_info["shares"] = stock_shares[0]["SUM(shares)"] stock_info["total"] = stock_info["shares"] * stock_info["price"] stocks.append(stock_info) I see that it says stock_info["shares"] (and therefore stock_shares[0]["SUM(shares)"], but again, when querying for this, I am getting real values) is the NoneType, but where does that happen? Strangely enough, this doesn't seem to be a problem for all users. Some of my users can access their index/portfolio page with no problems, whereas others run into this error every time, even upon login.
Thoughts?