Sunday, October 11, 2009

Uploading Data to App Engine

Pre-requisite:
  1. You know some Django
  2. Your Django App Engine app is working properly on your dev server
Here are the relevant lines in the app.yaml file that will ensure data upload to the live server:

handlers:
- url: /load
script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
login: admin
Make sure the above is the very first item in the handlers section because yaml file is parsed top to bottom.
  • Upload your latest source file to your app engine account
  • Test to see if the following url is accessible:
    http://yourapp.appspot.com/load
    Your should either be prompted to authenticate into your Google Account or get the following message if you are already authenticated:
    This request does not contain a necessary header
The above confirms that the upload can take place. The app.yaml in some ways behave as a Django's urls.py or Routes in Rails. Proceed with the usual data upload command:


appcfg.py upload_data --config_file=yourapp/module/module_loader.py --filename=yourapp/fixtures/data.csv --kind=Module yourapp

No comments: