當前位置: 首頁>>代碼示例>>Python>>正文


Python Exercise.put方法代碼示例

本文整理匯總了Python中models.Exercise.put方法的典型用法代碼示例。如果您正苦於以下問題:Python Exercise.put方法的具體用法?Python Exercise.put怎麽用?Python Exercise.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.Exercise的用法示例。


在下文中一共展示了Exercise.put方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: post

# 需要導入模塊: from models import Exercise [as 別名]
# 或者: from models.Exercise import put [as 別名]
	def post(self):
		workout_title = self.request.get("workout")
		new_workout = Workout(parent = PARENT_KEY, title = workout_title)
		new_workout.put()
		arguments = self.request.arguments()
		exercises = [ {} for i in range( utils.findLength(arguments) ) ]
		print exercises
		for argu in arguments:
			if str(argu) != 'workout':
				num = utils.findPosition(argu)
				if utils.is_time(argu):
					exercises[num]['time'] = int(self.request.get(argu))
				if utils.is_rest(argu):
					exercises[num]['rest'] = int(self.request.get(argu))
				if utils.is_name(argu): 
					exercises[num]['name'] = str(self.request.get(argu))
		print exercises
		for counter, exercise in enumerate(exercises): ## Needs to be ordered
			print counter
			print exercise
			new_exercise = Exercise(parent = PARENT_KEY, 
									name = exercise['name'],
									time = exercise['time'],
									rest = exercise['rest'],
									workout_title =  workout_title,
									order =  counter)
			new_exercise.put()

		self.redirect('/home') 
開發者ID:samoretc,項目名稱:Workout-Timer,代碼行數:31,代碼來源:main.py

示例2: post

# 需要導入模塊: from models import Exercise [as 別名]
# 或者: from models.Exercise import put [as 別名]
	def post(self):
		upload_files = self.get_uploads()
		used_methods = list()
		for method in test_methods:
			if self.request.get(method):
				used_methods.append(method)

		inputs = list()
		for i in string.replace(self.request.get('test_input'), '\r', '').split(';'):
			inputs.append(db.Text(i))

		outputs = list()
		for o in string.replace(self.request.get('output'), '\r', '').split(';'):
			outputs.append(db.Text(o))

		if len(inputs) != len(outputs):
			self.write("Error: Number of inputs did not match number of outputs.")
		else:
			keywords = string.replace(self.request.get('keywords'), '\r', '').split(';')
			checker = ExerciseChecker(	test_methods=used_methods,
										inputs=inputs,
										outputs=outputs,
										keywords=keywords)
			checker.put()

			start_code=string.replace(self.request.get('start_code'), '\r', '')

			description = self.request.get('description')
			description = string.replace(description, '\r', '')
			description = string.replace(description, '\n', '<br>')

			exercise = Exercise(name=self.request.get('name'), 
								url=self.request.get('url'), 
								description=description,
								start_code=start_code,
								checker=checker)

			if len(upload_files):
				exercise.flowchart = upload_files[0].key()
			exercise.put()
			time.sleep(5)
			self.redirect('/exercises/'+exercise.url)
開發者ID:chrisuehlinger,項目名稱:sg-study-c,代碼行數:44,代碼來源:views.py


注:本文中的models.Exercise.put方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。