michael@d2m.at  |  +43 (664) 948-8084
You are here: Home Blog 2009 06 22 bobo & GAE

bobo & GAE

by Michael Haubenwallner last modified Jun 26, 2010 10:13 PM

A blueprint on how to setup a new GAE project and run a basic bobo application on top of it.

First download and install the Google App Engine SDK, here is a Tutorial to get you started.

Next create an new package bobo_project. Inside bobo_project add an __init__.py file with empty contents.

    # a package

Now create the app.yaml file. It defines the application id and a single wildcard URL handler:

    application: your-application-id
    version: 1
    runtime: python
    api_version: 1
    
    handlers:
    - url: /.*
      script: main.py

The main.py file creates, configures and runs the bobo WSGI application:

    import bobo
    import google.appengine.webapp.util
    
    bobo_app_name='project'
    
    def main():
        application = bobo.Application(bobo_resources=bobo_app_name)
        google.appengine.webapp.util.run_wsgi_app(application)
    
    if __name__ == '__main__':
        main()

project.py is the basic bobo web application:

    import bobo
    
    @bobo.query('/')
    def hello(name='world'):
        return 'Hello %s' % name

Finally add bobo.py (part of the bobo package) and - if you intend to use JSON - the simplejson package to the project folder (GAE runs on Python2.5).

The project layout now looks like:

    bobo_project/
      __init__.py
      app.yaml
      bobo.py
      main.py
      project.py
      simplejson/

Test-drive your project locally with the dev_appserver:

    gae$ python dev_appserver.py bobo_project &
    gae$ firefox http://localhost:8080/

Create a new appspot project 'your-application-id' and upload bobo_project into it:

    gae$ python appcfg.py update bobo_project

Access your application online:

    gae$ firefox http://your-application-id.appspot.com/

Comment

Posted by Dirk Holtwick at 2009-06-23 06:13:17
On GAE you don't need to install simplejson, it is already there. Just do:

from django.utils import simplejson

Also you could use Pyxer for installing other packages inside the Bobo project using the built in easy_install support. See:

http://code.google.com/p/pyxer/wiki/ShortSummary#Setup_a_new_project

Comment

Posted by d2m at 2010-02-05 06:57:16
Update: changed source to use google.appengine.webapp.util.run_wsgi_app. Read more on possible exploits through wsgiref.handlers.CGIHandler on http://dirtsimple.org/2010/02/don-use-cgihandler-on-google-app-engine.html
Filed under: , , , ,