我希望使用任务队列修改1000个实体,正如我在这里的原始问题中Zig Mandel所建议的:Google App Engine: Modifying 1000 entities
我有这样一个用户帐户:
class UserAccount(ndb.Model):
email = ndb.StringProperty()
一些UserAccountemail
包含大写字母(例如:JohnathanDough@email.com),我想对每个实体的电子邮件应用email.lower()
。你知道吗
所以我设置了一个任务队列如下:
class LowerEmailQueue(BaseHandler):
def get(self):
all_accounts = UserAccount.query().fetch()
for a in all_accounts:
taskqueue.add(url = '/lower-email', params = {'account_id': a.key.id()})
class LowerEmail(BaseHandler):
def post(self):
account_id = self.request.get('account_id')
account = UserAccount.get_by_id(int(account_id))
account.email = account.email.lower()
account.put()
app = webapp2.WSGIApplication([
('/', MainPage),
('/lower-email-queue', LowerEmailQueue),
('/lower-email', LowerEmail),
], debug=True)
我还没有运行这个,因为我想防止对我的数据造成灾难性的破坏。这样行吗?你知道吗
不,事实上,这不会做任何事情,因为你不会做任何事情与降低电子邮件地址。你需要把它分配回实体。你知道吗
相关问题 更多 >
编程相关推荐