Note
This feature is still an experimental. The implementation might change in the future.
Let me introduce you some of useful packages from kay.ext package.
nuke is a small tool for wipe all of your data in one action.
To use kay.ext.nuke, firstly you need to retrieve bulkupdate copy from github repository, put it under your project directory, add kay.ext.nuke to your settings.INSTALLED_APPS variable, and add these few lines to your app.yaml file.
admin_console:
pages:
- name: Bulk Update Jobs
url: /_ah/bulkupdate/admin/
- name: Nuke
url: /_ah/nuke/
handlers:
- url: /_ah/nuke/.*
script: kay/main.py
login: admin
- url: /_ah/bulkupdate/admin/.*
script: bulkupdate/handler.py
login: admin
Then you will see Nuke menu on your admin console, or you can just visit /_ah/nuke directly.
kay.ext.gaema is a package for supporting authentication using some social services. Currently following services are supported.
kay.ext.gaema.services module has constants for these service names:
All of following functions have service as its first argument, a value of service must be one of service names above.
To use twitter or facebook, you need to register your application on the service’s website, and set your keys to settings.GAEMA_SECRETS dictionary.
kay.ext.gaema.utils package has following functions.
kay.ext.gaema.decorators package has following decorators.
Here is a simple example that shows how to authenticate users with twitter OAuth. Firstly, you need to register your application on Twitter’s website, and set a key and secret from twitter to settings.GAEMA_SECRETS as well as settings.INSTALLED_APPS, and activate kay.sessions.middleware.SessionMiddleware as follows:
INSTALLED_APPS = (
'myapp',
'kay.ext.gaema',
)
GAEMA_SECRETS = {
"twitter_consumer_key": "hogehogehogehogehogehoge",
"twitter_consumer_secret": "fugafugafugafugafugafugafugafuga",
}
MIDDLEWARE_CLASSES = (
'kay.sessions.middleware.SessionMiddleware',
)
Here is an example for views:
# -*- coding: utf-8 -*-
# myapp.views
import logging
from werkzeug import Response
from kay.ext.gaema.utils import (
create_gaema_login_url, create_gaema_logout_url, get_gaema_user
)
from kay.ext.gaema.decorators import gaema_login_required
from kay.ext.gaema.services import TWITTER
from kay.utils import (
render_to_response, url_for
)
# Create your views here.
def index(request):
gaema_login_url = create_gaema_login_url(TWITTER,
url_for("myapp/secret"))
return render_to_response('myapp/index.html',
{'message': 'Hello',
'gaema_login_url': gaema_login_url})
@gaema_login_required(TWITTER)
def secret(request):
user = get_gaema_user(TWITTER)
gaema_logout_url = create_gaema_logout_url(TWITTER,
url_for("myapp/index"))
return render_to_response('myapp/secret.html',
{'user': user,
'gaema_logout_url': gaema_logout_url})