kay /

Filename Size Date modified Message
100 B
774 B
2.7 KB
1.5 KB
5.3 KB
1.3 KB
891 B
168 B
1003 B
751 B
312 B
Kay Framework

What's this

Kay is a web framework completely specialising on Google App
Engine. But basic design is based on the Django framework, like
middleware, settings and pluggable application, etc. Kay uses Werkzeug
as lower level framework, uses Jinja2 as template engine, uses babel
for handling language translations. This software is distributed under
BSD license. See LICENSE for the details.

The software that Kay bundles
* babel
* jinja2
* simplejson
* werkzeug
* pytz

* Google App Engine SDK

  If you installed zip version of the SDK(most unix style operation
  system users are so), don't forget to create a symlink pointed to
  the real SDK at /usr/local/google_appengine.
.. code-block:: console

   $ sudo ln -s /some/whare/google_appengine /usr/local/google_appengine    

Quick Start

* First, make symlynk of kay directory inside your project directry,
  copy settings files.

.. code-block:: console

   $ hg clone
   $ mkdir yourproject
   $ cd yourproject
   $ ln -s ../kay/kay .
   $ ln -s ../kay/ .
   $ cp ../kay/ .
   $ cp ../kay/ .
   $ cp ../kay/app.yaml .

* Second, you can create your first application with following command.

.. code-block:: console

   $ python startapp hello
   $ vi

You have to add 'hello' to the INSTALLED_APPS tupple in the For the details of how to define urls and views for your
application, please refer to docs/urlmapping.rst.


.. code-block:: python


* Run your application

.. code-block:: console

  $ python runserver

You can access your first application on the url:

* Upload your application

.. code-block:: console

  $ python appcfg update

* You can handle i18n like following. For the details of i18n, please
  refer to docs/i18n.rst.

.. code-block:: console

   $ python extract_messages hello
   $ python add_translation hello -l ja
   $ vi hello/i18n/ja/LC_MESSAGES/messages.po
   $ python compile_translations hello

You can also merge newly added catalogue into your translations as

.. code-block:: console

   $ python extract_messages hello
   $ python update_translation hello -l ja
   $ vi hello/i18n/ja/LC_MESSAGES/messages.po
   $ python compile_translations hello

Shell tools

* Invoking `python shell` gives you python (or ipython if
  available) console session with the same DatastoreFileStub settings
  of local dev server. For the details of commands, please
  refer to docs/manage_py.rst.


  The local dev server reads datastore data file only on startup. So,
  the dev server will never notice about the datastore operation on
  your console session. You must restart your dev server for
  reflecting the result of the console sessions.

* Invoking `python rshell` is the same as above except for
  using RemoteDatastore stub. You can access the data on the
  production server.

  Please be careful when you use this feature.


* You must use GAE models directly. You can use kay.utils.forms for
  form handling. You can construct a form automatically from the model
  definition with kay.utils.forms.modelform.ModelForm. For the details
  of how to use forms, please refer to docs/forms-usage.rst.

* By default, db.Model.kind() returns ('model's app name' + _ + 'model
  name').lower(). So when you see the management console, there will
  be 'appname_modelname' style kind names . Please don't be surprised
  with those names.

  You can change this behaviour by settings ADD_APP_PREFIX_TO_KIND to
  False in your


* To define form class, you can define a class that extends
  kay.utils.forms.Form. For example the code bellow will give you the
  form contains two text fields with different validators.

.. code-block:: python

    from kay.utils.forms import Form
    class PersonForm(Form):
      name = TextField(required=True)
      age = IntegerField()

You can use this form in your view like following.
.. code-block:: python

    from forms import PersonForm
    form = PersonForm()
    if request.method == 'POST'
      if form.validate(request.form, request.files):
        name = form['name']
	age = form['age']
        do something with valid form ...
        do something with invalid form ...

* You can also use ModelForm to create a form automatically from Model

.. code-block:: python

    from google.appengine.ext import db

    class MyModel(db.Model):
      name = db.StringProperty(required=True)
      age = db.IntegerProperty()

    from kay.utils.forms.modelform import ModelForm

    class MyForm(ModelForm):
      class Meta:
        model = MyModel


* URL Mapping

* Form manual

* i18n

* Management script

Questions and Bug Report

* Please visit Kay framework google group.
* Or, contact the project leader directly.
  Takashi Matsuo <>

* Code site

Have fun!