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


Python Post.create_new方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import create_new [as 别名]
    def post(self):
        """
        Add a new post, and redirect to the permalink page
        """

        if not self.user:
            self.abort(403)


        upload_files = self.get_uploads('file')  # 'file' is file upload field in the form
        blob_info = upload_files[0]
       # if(blob_info):
        #    self.redirect('/dashboard/%s' % blob_info.key())

        caption = self.request.get('caption')
        blobKey = blob_info.key()
        user = self.user
        #author = self.request.get('group')
        #college = self.request.get('college')

        try:
            post_id = Post.create_new(caption=caption, blobKey=blobKey, user=user)
            self.redirect('/post/%s' % post_id)

        except Exception, e:
            self.render('newpost.html', 
                        post={'caption' : caption, 'blobKey' : blobKey},
                        user=self.user,
                        error=e)
开发者ID:kaushikdr,项目名称:campus,代码行数:31,代码来源:views.py

示例2: post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import create_new [as 别名]
	def post(self, post_id1):
		title = self.request.get('title')
		content = self.request.get('content')
		user = self.user
		post = Post.get_by_id(int(post_id1))
		if not user:
			self.abort(403)

		try:
			post_id = Post.create_new(title=title, content=content, user=user,comment=post.comment )
			post.key.delete()
			self.redirect('/post/%s' % str(post_id))

		except Exception, e:
			self.render('newpost.html', 
						post={'title' : title, 'content' : content},
						user=self.user,
						error=e)
开发者ID:shantamdas,项目名称:mypostsd,代码行数:20,代码来源:views.py

示例3: post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import create_new [as 别名]
	def post(self):
		"""
		Add a new post, and redirect to the permalink page
		"""

		title = self.request.get('title')
		content = self.request.get('content')
		user = self.user

		if not user:
			self.abort(403)

		try:
			post_id = Post.create_new(title=title, content=content, user=user)
			self.redirect('/post/%s' % str(post_id))

		except Exception, e:
			self.render('newpost.html', 
						post={'title' : title, 'content' : content},
						user=self.user,
						error=e)
开发者ID:CampusHash,项目名称:blogey,代码行数:23,代码来源:views.py


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