本文整理汇总了Python中models.Job.get_by_key_name方法的典型用法代码示例。如果您正苦于以下问题:Python Job.get_by_key_name方法的具体用法?Python Job.get_by_key_name怎么用?Python Job.get_by_key_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Job
的用法示例。
在下文中一共展示了Job.get_by_key_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Job [as 别名]
# 或者: from models.Job import get_by_key_name [as 别名]
def post(self, job_id):
job = Job.get_by_key_name(job_id)
# make sure the job is recent
if not(job.active):
self.error(404)
email = job.email
email.enable = False
email.updated_at = datetime.datetime.now()
email.put()
# find the email-club join
join_query = EmailToClub.all()
join_query.filter("email =", email)
joins = join_query.fetch(20)
# do the delete
for join in joins:
join.enable = False
join.updated_at = datetime.now()
join.put()
# mark all the jobs inactive
job_query = Job.all()
job_query.filter("email =", email)
job_query.filter("active =", True)
jobs = job_query.fetch(20)
for job in jobs:
job.active = False
job.put()
self.response.out.write(template.render("templates/sorry.html", {}))
示例2: get
# 需要导入模块: from models import Job [as 别名]
# 或者: from models.Job import get_by_key_name [as 别名]
def get(self, job_id):
job = Job.get_by_key_name(job_id)
if job and job.state != DONE and job.active == True:
job.updated_at = datetime.now()
job.state = DONE
job.put()
# update the email
email = job.email
email.updated_at = datetime.now()
email.put()
# count the number of jobs attached to this flyer
job_query = Job.all()
job_query.filter("flyer =", job.flyer)
job_query.filter("active =", True)
total_jobs = job_query.count()
# count the number of jobs done so far
job_query = Job.all()
job_query.filter("flyer =", job.flyer)
job_query.filter("active =", True)
job_query.filter("state =", DONE)
done_jobs = job_query.count()
# write out
self.response.out.write(template.render("templates/finish.html",
{"total": total_jobs,
"done": done_jobs}))
else:
self.error(404)