Wednesday, July 22, 2009

Basic Google App Engine command line

Some basic Python SDK commands in Google App Engine
  • dev_appserver.py - the development web server
  • appcfg.py - for uploading your app to App Engine
To run a local instance of a site named mysite within the Google App Engine localserver, invoke command line:

dev_appserver.py mysite (as opposed to python manage.py runserver)

When it comes to starting a project you can opt for either the built-in 0.96 of Django that is in the SDK or alternately bootstrap a 1.x version of Django. If the built-in is satisfactory, the first step in creating the new app engine site is identical to starting a self-standing Django project:

django-admin.py startproject mysite

If you choose the latter method, you will have more flexibility with the latest features of Django. This requires a different startup. You can simply checkout the latest helper app from google code. This serves as a platform for the applications you plan to create. Here's the command line:

svn checkout http://google-app-engine-django.googlecode.com/svn/trunk/ mysite

So now you're all set with a base. Don't forget that with 1.x of Django, you have to put in the Django library locally, probably best using the zipimport method, the details of which are in an earlier post on this blog. Regardless of which Django version you opt for, creating an application is done thus:
python manage.py startapp myapp
Next, begin connecting the apps as you would in Django standalone, via urls.py. There are also special requirements using the App Engine datastore instead of an relational database. More info on the differences can be found here.

No comments: