Tuesday, November 26, 2013

Changes 11/25/13

Math Drill:

  • Wrote a login.tpl page with user and password fields
  • Researched hashing algorithms and how to safely store passwords
  • Began creating a database to hold username and password and eventually other stuff

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

Thursday, November 21, 2013

Changes 11/21/13 Part 2

Math Drill:

  • Made a .vimrc file to set tab to four spaces, which makes python programming much easier
  • Added comments to postStudents() method explaining what certain code does
  • Saved the <textarea> input to a variable so that it can be parsed and added to students[]
  • Learned that you can write mergedList = list1 + list2, which is good to know for future code 
  • Keep running into weird problems where the server will give a 500 page but not output any python errors.  This is frustrating and it is very hard to tell what is going wrong.

Changes 11/21/13 Part 1

Math Drill:

  • Fixed the list of deletions not checking against the right string
  • Used '<br>'.join(debuglist) to easily print the list of students in html form, this is a pretty useful python function
  • Checking the delete box now removes that student from the students[] list, but not the text file (yet)
  • Got a lot of "internal server error" without a stack trace or anything, so that took a while to fix.  I still don't know what was causing that
  • Added a textarea for entering additional students

Wednesday, November 20, 2013

Changes 11/20/13

Post-Note:

Math-Drill:

  • Added page /admin/students, which dynamically generates a list of all the students names with checkboxes next to them, using embedded code in the template file
  • % for student in students:
        {{student}}: <input type="checkbox" name="{{student}}_delete" value="Delete"><br>
    % end
  • Added method to POST /admin/students/submit
  • Submit button returns a page listing which students are being kept and deleted (although nothing actually changes yet)

Tuesday, November 19, 2013

Changes 11/19/13

Post Note:

  • Fixed the "_blank" attribute on the form, which was causing a new tab to open
  • Updated css to style the page
  • Added bottle.redirect('/') so that the pages refreshes when submit is pressed
  • Updated form to have two text boxes, one for the submitter name and one for the actual text
  • Added checks to make sure the data has been submitted properly without blank fields

Friday, November 15, 2013

Changes 11/15/13

Post-note (Bottle app):

  • Simple bottle app to look at how POST works for bottle and web forms in general
  • Text box allows for text entry, and when submit is clicked, the text from the text box is put in a variable, which is then set to a <h2> element
  • Code was largely copied from Math Drill and adapted
  • Learned about the app.post() method and how it interfaces with the webpage
  • Learned about the python global keyword and how it is used
  • Interestingly, the global  message variable seems to clear itself after awhile; I assume this is due to Google's hosting servers wanting to save resources
  • App was uploaded to Google App Engine (after learning the process with Math Drill it was really easy, too)
  • App is live at www.post-note.appspot.com
  • Styling and other stuff is eventually going to be added
  • The code will probably be cleaned up, since this is serves as a good example for how POST works in bottle