2008-07-11

Getting started with Zope on Google App Engine

Thanks to a patch published by Kapil Thangavelu, it's quite straight-forward to get set up to use Zope on Google's App Engine. Yesterday, Guido van Rossum provided a zipimport-implementation which makes it easy to import Python libraries as a ZIP-archive, which was previously not possible in the remote environment.

To make it easier for everyone to get started, I thought I'd publish my setup.

You'll need to dump a ZIP-archive of the packages you want to use in your application directory. Download zope.zip to get the basic necessities.

Put Guido's my_zipimport.py in the Python path and bootstrap the importer using the following code:
  import my_zipimport
import sys

my_zipimport.install()
sys.path.insert(0, 'zope.zip')
You'll probably want to look at Ian Bicking's instructions for getting a Pylons-based application set up and the customize it to point to an application factory such as this:
  import os

def application_factory(global_conf, zcml='site.zcml', devmode='off', **kwargs):
zcml_conf = os.path.join(global_conf['here'], zcml)
devmode = ( devmode.lower() in ('true', 'True', 'on') and True) or False
return getWSGIApplication(zcml_conf, devmode)

def getWSGIApplication(configfile, schemafile=None, features=()):
return WSGIPublisherApplication()

class WSGIPublisherApplication(object):
def __call__(self, environ, start_response):
start_response('200 OK', [('Content-type', 'text/plain')])

yield "Hello World!"
This is very preliminary, but should give some starting pointers. For an example on how a WSGI application can interact with the Zope publisher, you may want to look at ore.wsgiapp.

1 comments:

reco said...

yes malthe nice
vudo + Goolge AE = Voodge
:)