Project 9: A Blog

In this project you'll use complicated data structures built from Python dictionaries and lists.


Turn in exercises 38 and 39 with this assignment.


Start by downloading the code attached to this week's lecture. It contains a basic implementation of a blog. The blog loads and saves data to a file. It contains the following functions:

  • load_blogs - Loads blog data from a file
  • save_blogs - Saves blog data to a file
  • create_user - Creates a user on your blog site
  • add_post - Creates a post on the blog site.

The functions are documented in the code. Be sure you understand what they do and how they work. Rename in my example code to and use it to start your project.

Adding Functions

Your code should add the following functions to the blog system:

  • list_users - List the users in your blog site
    • Arguments:
      • The blog data structure
    • Returns:
      • A list containing the usernames of every registered blogger
  • user_summary - List all of the blog titles for a particular user
    • Arguments:
      • The blog data structure
      • The username of a user
    • Returns:
      • A list containing blog entry titles.
  • update_user_info - Change a user's real name email address
    • Arguments:
      • The blog data structure
      • The username of a user
      • A new real name to set (or None to keep the user's name unchanged)
      • A new email address to set (or None to keep the user's email unchanged)
    • Returns:
      • None
  • delete_post - Delete a post from a user
    • Arguments
      • The blog data structure
      • The username of a user
      • The post number to delete
    • Returns
      • The deleted post

Testing Your Functions

You are responsible for testing your functions in your main() function. When I test your program I will not call your main() function. I will test your functions individually. Here's a good way to start:

def main() :
    # Load data from blog_data.json file 
    bloggers = load_blogs('blog_data.json')
    # Call your functions here
    # Save data to a different file. Check this file to see if your changes happened. 
    save_blogs(bloggers, 'blog_data.json.out')


  • Your program must be called
  • Your file must have a docstring
  • Each function must have a docstring
  • The functions must match the specification above

Advanced Project

The notes for this week's class contains a blog project that runs in Flask and is compatible with Google App Engine. Follow the instructions on Google's Quickstart Guide:

Remember, GAE requires that you use Python 2.7. You can do that from your Cloud9 workspace (which I recommend). When using Cloud9 there's one important change you have to make. When you run the command be sure to add the –host= argument. For example: --host= app.yaml

That's required because of the way Cloud9 works.

Submit a screenshot of the getting Hello World app hosted by Google.


  • 5 points for the exercises
  • 5 points for a correct submission
  • 10 points for the correctness of the program