Friday, June 25, 2010

Google AppEngine support in KalaPy!

Hello Everyone,

I have just implemented Google AppEngine support in KalaPy. You can see a KalaPy example running on AppEngine.

As I mentioned earlier in my previous post, the DAL API has been changed to deal with GAE related issues. Let me make some corrections regarding these changes.

The NOT IN operator has been removed (this can be done with multiple != filters). The OR operation should be performed with Q like this:
from kalapy.db import Query, Q
from models import User

q1 = User.all().filter(Q('name ==', 'some')|Q('name ==', 'someone'))

q2 = User.all().filter('name ==', 'some') \
               .filter('lang ==', 'fr_FR')
The q1 is equivalent to:
SELECT * FROM "hello_user" WHERE "name" = 'some' OR "name" = 'someone'
And the q2 is equivalent to:
SELECT * FROM "hello_user" WHERE "name" = 'some' AND "lang" = 'fr_FR'
There are still some issues with GAE backend implementation, especially:
  • Referential integrity is not implemented yet
  • Unique constraint is not implemented yet
  • OneToOne field will not work as expected
  • Decimal field is not supported at the moment
  • Transaction is not supported
The issues will be resolved before releasing KalaPy 0.3 which I am planing to release during the first week of the coming July.

Beside that, I have also implemented an admin command to deal with GAE related tasks like create app.yaml, launching dev appserver, updating the application on appengine etc.
$ cd /path/to/your-kalapy-project
$ ./admin.py gae --help
admin.py gae <action> [options] [args]

Perform google appengine specific tasks.

Use the 'appcfg.py' and 'dev_appserver.py' (included in appengine sdk)
for other appengine specific tasks.

options:

  -a --address hostname for the appserver
  -p --port    port number for the appserver
  -i --install install libs (extra libs as arguments)
  -v --verbose enable verbose output
  -h --help    display help and exit

available actions:

  prepare    prepare this project for google appengine.
  rollback   launch 'appcfg.py rollback'
  runserver  launch 'dev_appserver.py runserver'
  update     launch 'appcfg.py update'
You can install required python modules with ./admin.py gae prepare -i [module1 [module1 [...]] command. For example, with KalaPy example application (change settings.DATABASE_ENGINE = "gae"):
$ cd /path/to/kalapy/example
$ ./admin.py gae prepare -i docutils roman
$ ./admin.py gae runserver
Get the latest sources from the github and help me improving the project. Visit the official project website for latest updates.

Regards

0 comments: