本文整理汇总了Python中models.File.query方法的典型用法代码示例。如果您正苦于以下问题:Python File.query方法的具体用法?Python File.query怎么用?Python File.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.File
的用法示例。
在下文中一共展示了File.query方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import query [as 别名]
def get(self):
logging.info("Starting to clean the datastore")
courses = Course.query()
for key in courses.iter(keys_only=True):
files = File.query(ancestor=key)
if files.get() is None:
key.delete()
logging.info("Deleting: " + key.string_id())
logging.info("Done cleaning the datastore")
示例2: get
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import query [as 别名]
def get(self, dept):
template = main.jinja_env.get_template("templates/main.html")
values = {"departments": models.DEPARTMENT_NAMES, "types": models.FILE_TYPES}
values["dept"] = dept
termcodes = []
this_year = date.today().year + 1
this_month = date.today().month
for year in range(this_year, this_year - 3, -1):
yearcode = year * 100
for quarter, value in [('Spring', 30), ("Winter", 20), ("Fall", 10)]:
termcodes.append({"term":quarter + " " + str(year - 1) + "-" + str(year) ,"code":yearcode + value})
values["termcodes"] = termcodes
if 1 <= this_month <= 2:
# Winter Quarter
values["termcodes"] = termcodes[4:]
elif 3 <= this_month <= 6:
# Spring Quarter
values["termcodes"] = termcodes[3:]
elif 7 <= this_month <= 8:
# Summer
pass
elif 9 <= this_month <= 11:
# Fall Quarter
values["termcodes"] = termcodes[2:]
elif this_month == 12:
# Winter Quarter
values["termcodes"] = termcodes[1:]
course_keys = Course.query(Course.department == dept)
courses = []
files = {}
for course_key in course_keys.iter(keys_only=True):
courses.append(course_key.string_id())
files[course_key.string_id()] = File.query(ancestor=course_key)
courses.sort()
values["courses"] = courses
values["files"] = files
self.response.out.write(template.render(values))