本文整理汇总了Python中models.Exercise.query方法的典型用法代码示例。如果您正苦于以下问题:Python Exercise.query方法的具体用法?Python Exercise.query怎么用?Python Exercise.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Exercise
的用法示例。
在下文中一共展示了Exercise.query方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: user_post
# 需要导入模块: from models import Exercise [as 别名]
# 或者: from models.Exercise import query [as 别名]
def user_post(self, *args):
pagename = args[0]
if args[0] is None:
pagename=""
exercise = Exercise.query().filter("url = ",pagename).get()
submission = self.request.get('code')
program = exercise.outside_code.format(submission)
action = self.request.get('action')
response = dict()
if action == 'check':
response = exercise.checker.checkWork(program, self.username)
if response['passed']:
user = User.query().filter('username = ', self.username).get()
if user and (not exercise.key() in user.exercises_completed):
user.exercises_completed.append(exercise.key())
user.put()
elif action == 'test':
message = ''
logging.info(self.request.get('input'))
response = exercise.checker.submit(program, self.username, self.request.get('input'))
if (response['error'] != "OK" or
int(response['result']) != 15 or
response['output'] is None):
message = response['error_message']
response['message'] = message
self.write_json(response);
示例2: get
# 需要导入模块: from models import Exercise [as 别名]
# 或者: from models.Exercise import query [as 别名]
def get(self):
workouts_query = Workout.query(ancestor = PARENT_KEY)
exercise_query = Exercise.query(ancestor = PARENT_KEY).order( Exercise.order )
template = jinja_env.get_template("templates/index.html")
print 'self response'
print self.response
self.response.write(template.render( {"workouts_query": workouts_query, "exercise_query" : exercise_query} ))
示例3: user_get
# 需要导入模块: from models import Exercise [as 别名]
# 或者: from models.Exercise import query [as 别名]
def user_get(self, *args):
pagename = args[0]
if pagename is None:
exercise_list = Exercise.query().order('name')
page = {'url':'exercises', 'topic_name':'Practice Exercises'}
self.render_with_user("exerciseindex.html", {'page':page,
'exercises':exercise_list})
else:
exercise = Exercise.query().filter("url = ",pagename).get()
if exercise is None:
self.write("No Exercise named '%s'" % pagename)
else:
logging.info("Serving exercise: " + repr(exercise.name))
logging.info("Serving exercise: " + repr(exercise.start_code))
logging.info("Serving exercise: " + repr(exercise.description))
self.render_with_user("exercise.html", {'page':exercise})