本文整理汇总了Python中models.Job.by_uuid方法的典型用法代码示例。如果您正苦于以下问题:Python Job.by_uuid方法的具体用法?Python Job.by_uuid怎么用?Python Job.by_uuid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Job
的用法示例。
在下文中一共展示了Job.by_uuid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Job [as 别名]
# 或者: from models.Job import by_uuid [as 别名]
def get(self, *args, **kwargs):
''' This method is called via ajax, renders job statistics '''
try:
job_id = self.get_argument("job_id")
except:
logging.warn("Bad argument passed to jobs ajax handler.")
self.render("blank.html")
return
user = self.get_current_user()
job = Job.by_uuid(job_id)
if job == None or user == None or user.id != job.user_id:
logging.warn("%s submitted request for non-existant job, or does not own job." % user.user_name)
self.render("cracking/jobs/ajax/error.html", message="Job does not exist")
else:
self.render("cracking/jobs/ajax/statistics.html", job=job)
示例2: post
# 需要导入模块: from models import Job [as 别名]
# 或者: from models.Job import by_uuid [as 别名]
def post(self, *args, **kwargs):
''' Deletes a job from the database '''
try:
job_id = self.get_argument("job_id")
except:
self.render("job/ajax_error.html", message="Job does not exist")
return
job = Job.by_uuid(job_id)
user = self.get_current_user()
if job != None and user != None and job.user_id == user.id:
dispather = Dispatch.Instance()
if job.name == dispather.current_job_name:
self.render("job/ajax_error.html",
message="Cannot delete job while it is in progress")
else:
job_name = str(job.name)
self.dbsession.delete(job)
self.dbsession.flush()
self.render("job/deletejob_success.html", job_name=job_name)
else:
logging.warn("%s attempted to delete a non-existant job, or a job he/she does not own." % user.user_name)
self.render("job/ajax_error.html", message="Job does not exist")