ancestor query with simpleauth

9 views
Skip to first unread message

yasuhiro toda

unread,
May 3, 2016, 11:04:56 AM5/3/16
to SimpleAuth for GAE
Hi, everyone

I have an issue regarding "ancestor query" with "simpleauth" login.

What I'd like to accomplish is to link the ID of "User" kind to the below Article class in "post" method of "ProfileHandler" class which "simpleauth" offers.

I have already placed "from webapp2_extras.appengine.auth.models import User" in the code.
What should I insert in "XXX" the below code?

I confirmed that "ID", "auth_ids", "avatar_url", "created", "link", "name", "password", "updated" have been created in "User" kind by accessing "Google Cloud Console" of "Datastore". 
However inserting "ID" or "id", "id()", key.id() didn't work...

I highly appreciate you could provide with any clue.

**********************
class ProfileHandler(BaseRequestHandler):
  def get(self):
    """Handles GET /profile"""
    if self.logged_in:
      self.render('profile.html', {
        'user': self.current_user,
        'session': self.auth.get_user_by_session()
      })
    else:
      self.redirect('/')

  def post(self):
    if self.logged_in:
      article = Article(parent=ndb.Key("User", XXX), title=self.request.get('title'), url=self.request.get('url2'), content=self.request.get('content'), genre=self.request.get('genre'))
      article.put()
*************************



Reply all
Reply to author
Forward
0 new messages