Create Multiple Versions

You may want to test your course in the production environment before you make it publicly available. Rather than have a truly private course in production, you can create a separate version of the course at a related, but unpublicized, URL. The key is that GAE allows versioning of your app and provides a separate URL for each version. (For details, see Requests and Domains).

Remember that if the name of your app is MYCOURSE, it’s available at http://MYCOURSE.appspot.com. You can use the version field in app.yaml to create and deploy a second version of the app. In this situation, you get a separate URL for that version. For example, if you specify version: latest, that gets deployed to http://latest.MYCOURSE.appspot.com.

Assume you have two different directories on your local machine, each of which contains code for a Course Builder course and each of their app.yaml files has the same value for the application parameter. If you run appcfg.py upload in both of these directories, GAE loads both applications to production and considers them to be the same application.

  • If the value of the version parameter is the same in both app.yaml files, then App Engine considers there to be only one version of the application and overwrites the first one loaded with the second one.
  • If the value of the version parameter is different in the app.yaml files, then App Engine considers there to be two versions of the application.
    • The first one you upload is the default version. That version is available at http://MYCOURSE.appspot.com and at http://VERSION.MYCOURSE.appspot.com, where VERSION is the value of the version parameter.
    • The second one you upload is a non-default version. It is available only at http://OTHERVERSION.MYCOURSE.appspot.com, where OTHERVERSION is the value of its version parameter.

Notice that a version doesn’t have to be a number; it can be any alphanumeric string (without spaces).

Change the default version

If you do nothing special, the first version of an application that is uploaded remains the default version (that is, the version you get when you simply enter http://MYCOURSE.appspot.com). Later versions do not automaically supercede it. You can change the default version yourself:

  1. Visit http://appengine.google.com.
  2. Choose your app.
  3. Click Versions in the left navigation.
  4. Pick the radio button for the version you want to be the default.
  5. Click Make Default.

Make “under construction” and “latest” versions

To create an “under construction” public version as the temporary default and a “latest” hidden version as a working version, follow steps similar to the following:

  1. Make two directories that contain the sample app.
  2. Edit the app.yaml file in each of them.
  3. In the directory for your temporarily public “under construction” version, specify mycourse as the value of application and specify underconstruction as the value of version.
  4. In the directory for your working version, specify mycourse as the value of application and specify latest as the value of version.
  5. In the under construction directory,
    1. Replace the entire contents of views/course.html with

      <html><body>Really under construction.</body></html>
      
    2. Replace the text in views/register.html with Under construction.
  6. In the working version directory, do all the work you need to create your course.
  7. Upload both versions to production, as described in Upload your app, making the app in the under construction directory be the default version, as described above.
  8. Test away.
  9. When you’re ready to release your application, hide the “under construction” version by changing the default version to your working version, which makes that one visible.

Hide your course from search engines

To further decrease the likelihood of someone stumbling upon your course, you can create a robots.txt file to tell search engines such as Google’s search engine to ignore your pages.

You add a robots.txt file to your application by creating that file and modifying app.yaml to know about it.

  1. Create a robots.txt file in the top-level of your application directory (the same place that contains app.yaml). In robots.txt, specify:

    User-agent: *
    Disallow: /
    

This tells robots (such as Google’s robots that crawl the web to create its index) to ignore everything in this site.

  1. In app.yaml, the handlers section looks like this:

    handlers:
    - url: /remote_api
    script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
    login: admin
    - url: /_ah/dev_admin(/.*)?  # provides interactive console
    script: $PYTHON_LIB/google/appengine/ext/admin
    login: admin
    secure: always
    - url: /.*
    script: main.app
    

Add a new entry to the top of handlers section as follows:

- url: /robots.txt
  static_files: robots.txt
  upload: robots.txt

Later, when you release the course, if you want it to be findable, you should reverse this change: remove the entry from app.yaml and delete the robots.txt file.

Run Course Builder tests

Course Builder contains a set of functional tests for its source code. If you make significant changes to the source code, consider running these tests. Depending on your changes, you may also have to modify the tests.

Run the tests with the following command:

python scripts/project.py --test *

Official GAE documentation

There’s a lot of official documentation for GAE.