【发布时间】:2014-07-01 22:16:20
【问题描述】:
我正在尝试基于电子邮件地址识别用户帐户(帐户实体)的 ndb 查询,然后删除该实体。帐户实体具有 access_lvl 的父级。
以下代码似乎没有正确获取帐户密钥和/或错误地使用 delete() 语句。
def access_lvl_key(website_sect_name=DEFAULT_WEBSITE_NAME):
"""Constructs a Datastore key for an Access_lvl entity with website_sect_name."""
return ndb.Key('Access_lvl', website_sect_name)
class Account(ndb.Model):
"""Models an individual access_lvl entry."""
email = ndb.StringProperty(required=True)
nickname = ndb.StringProperty(indexed=True)
date = ndb.DateTimeProperty(auto_now_add=True)
author = ndb.UserProperty()
@classmethod
def find_account(self, _email, _website_sect_name):
website_key = ndb.Key('Acess_lvl', _website_sect_name)
account = Account.query(Account.email == _email, ancestor=website_key)
return account.get()
class Deluser(webapp2.RequestHandler):
def post(self):
_website_sect_name = self.request.get('website_sect_name', DEFAULT_WEBSITE_NAME)
_email = self.request.get('email')
account = Account.find_account(_email, _website_sect_name)
ndb.Key('Account', account).delete()
最终,我想为 GAE 网站的某些部分创建一个基于帐户的访问列表,该列表将经过 Google 身份验证的帐户与 ndb 帐户列表进行匹配。如果有人碰巧有任何链接,我也会很感激。
【问题讨论】:
-
The following code doesn't seem to be picking up the Account key properly and/or is using the delete() statement incorrectly.你能说得清楚点吗?它到底(不)做什么?
标签: python google-app-engine app-engine-ndb