Develop and Deploy a Photo blog with database backend in Google App Engine: Tutorial


10 Mar  

After seeing the previous post on Google App Engine, some of my blog readers asked me to write another Google App Engine tutorial using tools available for Windows platform. In this edition, I am going to show you how to deploy a complex application like a Photo Blog in your Appspot account.

This tutorial requires the basic knowledge on the Google App Engine platform and you must know how to register new applications with Google App Engine (If not, please refer to this tutorial).

 

Setting up

Go to Google app engine downloads page and download the ‘SDK for Python’ (windows version). Once you have downloaded the ‘msi’ file, install the application by double clicking on it. This will allow you to install the SDK and by default it will opt for ‘C:/Program Files/Google/google_app_engine’ as the path.

SDK for Python windows

 

Now go to Python project website and download Python 2.6 to your system. Your Python interpreter will  be installed under the C:/Python26/ directory. Its time to register an application with Google App Engine. You can go the Google App Engine dashboard and register a new application.

 

google appspot - register

Done.

 

Setting up application

We are going to use the Nuages application for this tutorial. Since the project is using SVN, download and install SVN from Tigris website. Now go to command line and issue:

 

svn checkout http://nuages.googlecode.com/svn/trunk/ nuages-read-only

 

This will download the application source files to your system. It is advised that you create a directory and download the application to that one as shown below:

 

svn commandline

 

You need to customise the application before deployment

  • Edit app.yaml.default and settings.py.default to app.yaml and settings.py
  • Edit app.yaml in a text editor (notepad) and change the name of the application to yours
  • Also, edit settings.py and change the name of the application, URL (your appspot URL) , Name and Email

 

Deploying the application

 

Open the Google App Engine SDK which you have installed and go to File-> Create New Application. This will allow you to point to the source code (which you downloaded using SVN command).

You may also edit the settings by going to Edit->Preferences (Normally, the default values will work!)

 

google appspot sdk settings

 

Click on the application you selected (in the SDK window). Now you can see that some of the buttons in the toolbar have become active. Click on the deploy button to deploy the application to Google Cloud.

 

google appspot - sdk for windows - application listing 

The application will now ask you to give your email and password.

 

google appspot sdk for windows

 

And you will see and output like the one shown below (you may note that there is an error in the output, but for doing this tutorial you need not worry about that):

 

2010-03-10 03:48:20 Running command: "[u'C:\\Python26\\python.exe', 'C:\\Program Files\\Google\\google_appengine\\appcfg.py', '--no_cookies', u'--email=aasisvinayak@gmail.com', '--passin', 'update', u'C:\\Users\\vinayak\\python_app\\nuages-read-only']"
C:\Program Files\Google\google_appengine\appcfg.py:41: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
  os.path.join(DIR_PATH, ‘lib’, ‘antlr3′),
C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver_login.py:33: DeprecationWarning: the md5 module is deprecated; use hashlib instead
  import md5
Application: photoblog-from-techblog; version: 1.
Server: appengine.google.com.
Scanning files on local disk.
Initiating update.
Cloning 6 static files.
Cloning 24 application files.
Uploading 1 files and blobs.
Uploaded 1 files and blobs
Deploying new version.
Checking if new version is ready to serve.
Will check again in 1 seconds.
Checking if new version is ready to serve.
Will check again in 2 seconds.
Checking if new version is ready to serve.
Will check again in 4 seconds.
Checking if new version is ready to serve.
Will check again in 8 seconds.
Checking if new version is ready to serve.
Closing update: new version is ready to start serving.
Uploading index definitions.
Error 400: — begin server output —
Creating a composite index failed: This index:
entity_type: "Photo"
ancestor: false
Property {
  name: "date_posted"
  direction: 2
}

is not necessary, since single-property indices are built in. Please remove it from your index file and upgrade to the latest version of the SDK, if you haven’t already.
— end server output —
Your app was updated, but there was an error updating your indexes. Please retry later with appcfg.py update_indexes.
Password for aasisvinayak@gmail.com: 2010-03-10 03:48:49 (Process exited with code 0)

You can close this window now.

 

Your application has been deployed. You can go the application (appspot) URL to see the application. When you run this for the first time, it will ask you to go to the admin page.

 

 sample google appspot app

 

Click on the link (/admin/) and go to admin page (after signing into your Google account)

 

google accounts

 

It allows you to set the home page and add contents. You may note that we will be using the Google database (using GQL) for storing these information (which are already there in the code you uploaded).

 

google appspot - editing files

 

After setting the home page, you can see that you application is running in Google Cloud

 

google appspot - sample application in google cloud

 

Have Fun!

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay

Tags: , , ,


TechBlog on Facebook

Leave a Reply