当前位置: 首页>>代码示例>>Python>>正文


Python Job.get_by_key_name方法代码示例

本文整理汇总了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", {}))
开发者ID:thenoviceoof,项目名称:flyer-poke,代码行数:29,代码来源:flyer.py

示例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)
开发者ID:thenoviceoof,项目名称:flyer-poke,代码行数:30,代码来源:flyer.py


注:本文中的models.Job.get_by_key_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。