本文整理汇总了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)
示例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)
示例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)