本文整理汇总了Python中model.Post.save方法的典型用法代码示例。如果您正苦于以下问题:Python Post.save方法的具体用法?Python Post.save怎么用?Python Post.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Post
的用法示例。
在下文中一共展示了Post.save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import save [as 别名]
def post(self):
post = Post()
post.title = self.request.get('title_input')
post.content = self.request.get('content')
post.tags_commas = self.request.get('tags')
user = users.get_current_user()
post.author = user
post.catalog = self.request.get('blogcatalog')
private = self.request.get('private')
if private:
post.private = True;
else:
post.private = False;
#try: #no need this ugly permalink now!
# permalink = util.get_permalink(post.date,util.translate('zh-CN','en', util.u(post.title,'utf-8')))
# if not permalink:
# raise Exception
#except Exception:
# self.response.out.write("transalte error in title %s = %s<br />\n" % (post.title,util.get_permalink(post.date,util.translate('zh-CN','en', util.u(post.title,'utf-8')))))
# return
#check the permalink duplication problem.
#maxpermalinkBlog = db.GqlQuery("select * from Post where permalink >= :1 and permalink < :2 order by permalink desc",permalink, permalink+u"\xEF\xBF\xBD").get()
#if maxpermalinkBlog is not None:
# permalink = maxpermalinkBlog.permalink+ post.date.strftime('-%Y-%m-%d')
#post.permalink = permalink
post.save()
util.flushCategoryLists()
util.flushArchiveLists()
util.flushTagLists()
util.flushPublicPosts()
return self.redirect(post.full_permalink())
示例2: post
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import save [as 别名]
def post(self, subdomain, lense=None):
if self.request.headers['Content-type'] == 'application/json':
post = Post(**json.loads(self.request.body))
post.prefix = self.request.uri
post.author = self.current_user
post.save(db=self.db)
self.set_header('Location', post.url)
self.set_status(201)
else:
self.send_error(500)
示例3: put
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import save [as 别名]
def put(self, subdomain):
url = self.request.uri
if url.endswith('/'):
url = url[:-1]
if self.request.headers['Content-type'] == 'application/json':
if not url.endswith('.json'):
url = url + '.json'
try:
post = Post(**json.loads(self.request.body))
post.db = self.db
if post.author == self.current_user:
post.save(db=self.db)
self.set_status(204)
else:
self.set_status(403)
except:
self.send_error(500)
else:
self.send_error(500)