Skip to content

Instantly share code, notes, and snippets.

@michilu
Created May 13, 2011 23:23
Show Gist options
  • Save michilu/971498 to your computer and use it in GitHub Desktop.
Save michilu/971498 to your computer and use it in GitHub Desktop.
KeyError: '_service' in kay.ext.gaema.models.GAEMAUser.get_or_insert, discus for http://groups.google.com/group/kay-users-ja/browse_thread/thread/5a842d604c36d7a4
Traceback (most recent call last):
File "test0/kay/lib/werkzeug/wsgi.py", line 466, in __call__
return app(environ, start_response)
File "test0/kay/app.py", line 475, in __call__
response = self.get_response(request)
File "test0/kay/app.py", line 406, in get_response
return self.handle_uncaught_exception(request, exc_info)
File "test0/kay/app.py", line 372, in get_response
response = view_func(request, **values)
File "test0/myapp/views.py", line 44, in index
User.get_or_insert(key_name=user["email"], user=user)
File "test0/kay/ext/gaema/models.py", line 28, in get_or_insert
ds_user = cls.store_user_data(key_name, user)
File "test0/kay/ext/gaema/models.py", line 36, in store_user_data
service=user['_service'])
KeyError: '_service'
# -*- coding: utf-8 -*-
from google.appengine.ext import db
from werkzeug.wrappers import Response
from kay.ext.gaema.models import GAEMAUser
from kay.ext.gaema.services import GOOG_HYBRID
from kay.ext.gaema.utils import create_gaema_login_url, get_gaema_user, url_for
class User(GAEMAUser):
pass
def index(request):
template = '<a href="%(gaema_login_url)s">Sign in</a><br />%(user)s'
gaema_login_url = create_gaema_login_url(GOOG_HYBRID, url_for("myapp/index"))
user = get_gaema_user(GOOG_HYBRID)
if user:
User.get_or_insert(key_name=user["email"], user=user)
return Response(template % vars(), mimetype="text/html")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment