Friday, November 22, 2013

Changes 11/22/13

Math Drill:

  • Fixed 500 Internal Server error: I typed student.trim() rather than student.strip(), and it didn't print out the stack trace for some reason, making it very hard to troubleshoot
  • This was fixed in two ways:
    • Code was added to make it able to run with both python3 run.py and google_appengine/dev_appserver.py projects/math_drill/:
    • dev = False
      # If -l flag is used, run in python3 mode
      if (len(sys.argv) > 1 and (sys.argv[1] == '-l' or sys.argv[1] == '-local')):
          dev = True
          print('RUNNING IN LOCAL MODE (Non Google App Engine)')

      if dev:
          app = bottle
      else:
          app = Bottle()

      curdir = ''
      if dev:
          curdir = os.path.dirname(os.path.abspath(__file__)) + '/'


      ...
      # Other Code

      ...

      if dev:
          bottle.run()
      else:
          bottle.run(app=app, server="gae", debug=True)

    • The second, MUCH easier way of fixing the problem is simply to add debug=True to the bottle.run() statement (making it bottle.run(app=app, server="gae", debug=True)). This causes the stack trace to print on the 500 Internal Server Error page itself (although the stack trace still doesn't print in the console)
  • The add/remove students functionality of the /admin/students/ page finally seems to be working as intended

1 comment:

  1. The real distinction here is between running it on app engine and using bottle (Python's actually) built-in mini web server. You don't need to (and probably shouldn't) switch versions of python in the process. Just use the same Python version that app engine uses when running it locally.

    ReplyDelete