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


Python Point.update方法代码示例

本文整理汇总了Python中models.point.Point.update方法的典型用法代码示例。如果您正苦于以下问题:Python Point.update方法的具体用法?Python Point.update怎么用?Python Point.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.point.Point的用法示例。


在下文中一共展示了Point.update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from models.point import Point [as 别名]
# 或者: from models.point.Point import update [as 别名]
class Point_Controller:
	def __init__(self, db):
		self.db = db
		self.point_hook = Point(db)
		self.pv_hook = PV(db)

	# Utility
	def get_current_pv_id(self):
		cookie_data = request.get_cookie('spvm', dict(), secret='secret')

		if not isinstance(cookie_data, dict) and cookie_is_encoded(cookie_data):
			cookie_data = cookie_decode(cookie_data, 'key')

		if 'pv_id' not in cookie_data or cookie_data['pv_id'] is None:
			redirect('/')

		return cookie_data['pv_id']

	### New
	def get_new_point(self):
		points = self.point_hook.retrieve(where={'pv_id':pv_id, 'parent_id':''}, order="rank ASC", recursion=3)

		return template('point/new', title="New point", pv_id=self.get_current_pv_id(), points=points, errors=dict())
	get_new_point.route = '/point/new'
	get_new_point.method = 'GET'

	def ajax_get_new_point(self):
		points = self.point_hook.retrieve(where={'pv_id':self.get_current_pv_id(), 'parent_id':''}, order="rank ASC", recursion=3)

		return template('point/new', ajax=True, title="New point", pv_id=self.get_current_pv_id(), points=points, errors=dict())
	ajax_get_new_point.route = '/point/ajax/new'
	ajax_get_new_point.method = 'GET'

	def post_new_point(self):
		fields = dict()
		fields['pv_id'] = request.forms.pv_id
		fields['title'] = request.forms.title
		fields['description'] = request.forms.description
		fields['rank'] = request.forms.rank
		fields['parent_id'] = request.forms.parent_id

		validation_result = self.point_hook.create(fields)

		if isinstance(validation_result, dict):
			points = self.point_hook.retrieve(where={'pv_id':fields['pv_id']})

			return template('point/new', pv_id=fields['pv_id'], points=points, errors=validation_result)
		else:
			redirect('/pv/'+fields['pv_id'])
	post_new_point.route = '/point/new'
	post_new_point.method = 'POST'

	def ajax_post_new_point(self):
		fields = dict()
		fields['pv_id'] = request.forms.pv_id
		fields['title'] = request.forms.title
		fields['description'] = request.forms.description
		fields['rank'] = request.forms.rank
		fields['parent_id'] = request.forms.parent_id

		validation_result = self.point_hook.create(fields)

		if isinstance(validation_result, dict):
			return validation_result
		else:
			record = self.point_hook.retrieve_one(where={'id':validation_result})

			return {'id': validation_result, 'parent_id': record['parent_id'], 'number': self.point_hook.get_numbering(int(validation_result))}
	ajax_post_new_point.route = '/point/ajax/new'
	ajax_post_new_point.method = 'POST'

	### Edit
	def get_edit_point(self, point_id=None):
		data = self.point_hook.retrieve_one(where={'id':point_id})

		points = self.point_hook.retrieve(where={'pv_id':data['pv_id']})

		return template('point/edit', title="Edit point", data=data, points=points, errors=dict())
	get_edit_point.route = '/point/edit/<point_id>'
	get_edit_point.method = 'GET'

	def ajax_get_edit_point(self):
		data = self.point_hook.retrieve_one(where={'id':request.query.point_id})

		points = self.point_hook.retrieve(where={'pv_id':data['pv_id']})

		return template('point/edit', ajax=True, title="Edit point", data=data, points=points, errors=dict())
	ajax_get_edit_point.route = '/point/ajax/edit'
	ajax_get_edit_point.method = 'GET'

	def post_edit_point(self):
		fields = dict()
		fields['id'] = request.forms.point_id
		fields['pv_id'] = request.forms.pv_id
		fields['title'] = request.forms.title
		fields['description'] = request.forms.description
		fields['rank'] = request.forms.rank
		fields['parent_id'] = request.forms.parent_id

		validation_result = self.point_hook.update(fields, {'id': fields['id']})
#.........这里部分代码省略.........
开发者ID:sirzerator,项目名称:spvm,代码行数:103,代码来源:point.py


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