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


Python Post.by_route方法代码示例

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


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

示例1: view

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import by_route [as 别名]
 def view(self):
     year, month, day, route = self._get_route_args()
     post = Post.by_route(route)
     if post is None:
         return HTTPNotFound("No such post")
     form = BlogView.CommentForm(self.request.POST)
     if self.request.method == 'POST' and form.validate():
         if form.parent.data == '':
             post_comment = PostComment()
             post_comment.comment = Comment(form.name.data, form.email.data, form.body.data)
             post.comments.append(post_comment)
         else:
             parent_id = int(form.parent.data)
             parent_comment = Comment.by_id(parent_id)
             parent_comment.childs.append(
                 Comment(
                     form.name.data,
                     form.email.data,
                     form.body.data,
                     parent_id,
                     )
                 )
         return HTTPFound(
             location=self.request.route_url('post_view',
                 year=year,
                 month=month,
                 day=day,
                 route=RouteAbleMixin.url_quote(post.title))
             )
     return dict(
         form=form,
         post=post,
         pages=Page.all(),
         logged_in=authenticated_userid(self.request),
         )
开发者ID:daymien,项目名称:pymyblog,代码行数:37,代码来源:views.py

示例2: edit

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import by_route [as 别名]
 def edit(self):
     year, month, day, route = self._get_route_args()
     post = Post.by_route(route)
     if post is None:
         return HTTPNotFound('No such post')
     form = BlogView.Form(self.request.POST, post)
     if self.request.method == 'POST' and form.validate():
         post.title = form.title.data
         post.created = form.created.data
         post.body = form.body.data
         post.is_published = form.is_published.data
         # edit tags
         del post.tags
         for tag in Tag.from_list(form.tags.data):
             nt = NodeTag()
             nt.tag = tag
             post.tags.append(nt)
         return HTTPFound(
             location=self.request.route_url('post_view',
                 year=year,
                 month=month,
                 day=day,
                 route=RouteAbleMixin.url_quote(post.title))
             )
     return dict(
         post=post,
         form=form,
         pages=Page.all(),
         logged_in=authenticated_userid(self.request),
         )
开发者ID:daymien,项目名称:pymyblog,代码行数:32,代码来源:views.py

示例3: delete_comment

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import by_route [as 别名]
 def delete_comment(self):
     log.debug(self.request)
     request = self.request
     year, month, day, route = self._get_route_args()
     post = Post.by_route(route)
     if post is None:
         return HTTPNotFound('No such post')
     cid = int(request.matchdict['id'])
     comment = Comment.by_id(cid)
     post.delete_comment(comment)
     return HTTPFound(
             location=self.request.route_url('post_view',
                 year=year,
                 month=month,
                 day=day,
                 route=RouteAbleMixin.url_quote(post.title))
             )
开发者ID:daymien,项目名称:pymyblog,代码行数:19,代码来源:views.py


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