13 June 2010
This tutorials shows how to set up NetBeans IDE for writing Python for Google App Engine. Using NetBeans IDE is optional, you can complete the tutorial by skipping all the NetBeans related steps.
Google App Engine is for running web apps on Google's infrasturcture. NetBeans is a great IDE for any kind of programming language and it is crossplatform. So I am showing you how to bring theese two things together in Ubuntu Linux. You can use any IDE that knows Python, it's just a file editor, makes programming faster if you use code completion and good navigation. There are two programming languages to do that, there is Java and Python. In this tutorial we are going to use Python.

Get NetBeans:

First get any NetBeans IDE Bundle(PHP is the smallest, so I would go with that) from netbeans.org and install it. I am using version 6.8. Open NetBeans go to Tools-Plugins-Avaliable Plugins and install Python.

Get Google App Engine:

Now go download Google App Engine SDK for Python for Python: SDKs. Get the .zip, Linux version of the SDK. The zip contains all the necessary files to develop an application. Unpack the compressed file to some directory from where you are going to run it.

PATH:

Include the path to Google App Engine scripts into the systems PATH variable to launch its applications from a terminal using the command:
Source code viewer
  1. export PATH=$PATH:/path/to/your/google_appengine/
Programming Language: Bash
NB: The export command will work only during your current session.

Make Your Project:

Make a folder for your Google App Engine applications. Then make a subfolder for an application, the name will be in your google subdomain(application-name.appspot.com).

Create and fill two files that will go to the application folder:

app.yaml:
Source code viewer
  1. application: application-folder-name
  2. version: 1
  3. runtime: python
  4. api_version: 1
  5.  
  6. handlers:
  7. - url: /.*
  8.   script: index.py
Programming Language: YAML
index.py:
Source code viewer
  1. print 'Content-Type: text/plain'
  2. print ''
  3. print 'Hello, World!'
Programming Language: Python

Local Server:

Using the Terminal, navigate to the folder that you made for Google App Engine applications. App Engine is written in Python, so it requires it. Linux has python allready installed by default, if you have removed it then you have to install it back. Start the Google App Engine Web Server by following command:
Source code viewer
  1. dev_appserver.py your_application_folder_name
Programming Language: Bash
Click Y for updates. Now you can see results of the print commands in you browser from http://localhost:8080/. If you see "Hello, World!" in your browser then it works.

NetBeans IDE Project:

Now lets set up netbeans for your application. Create new project from File-"New Project...", make new Python project with existing sources. Thes select your "google_apps" folder. For project name you can write what ever you want, I wrote "Google Apps". It might take some time, if you have opened NetBeans Python project first time then it scans and indexes all of the python libraries.

Now lets add libraries for autocomplete. Go to your project properties and select Python tab. Add next folders from google_appengine folder, for me those directories are:
Source code viewer
  1. /home/user/google_appengine
  2. /home/user/google_appengine/lib/django
  3. /home/user/google_appengine/lib/webob
  4. /home/user/google_appengine/lib/yaml
Programming Language: Text

Make App Engine Account:

Now you probaby want your "Hello, World!" up to the internet. Go to appengine.google.com and make an account, if you allready have google account then that should do it. Including orkut, youtube, gmail and everything else that google owns.

Upload Your Site:

Log in and create an application, with the name of your application folder. If that name is taken then change the application folder name, don't forget to edit app.yaml aswell. Then run a command:
Source code viewer
  1. appcfg.py update /path/to/your/application/
Programming Language: Bash
The application should be up and running, you can go see it from application-name.appspot.com.