开发者

reddit get_comments action, can someone clarify what is going on here?

I'm trying to u开发者_运维百科nderstand reddit's source, and I am looking at the get_comments action method of front.py

This is the action that displays a story:

http://code.reddit.com/browser/r2/r2/controllers/front.py#L139

Specifically, what is the top part of the method doing where there is a @Validate marker?

And on the bottom near the return, it is sending objects to the view page.

Which viewpage is being called here?

211 res = LinkInfoPage(link = article, comment = comment,
212                            content = displayPane,
213                            subtitle = _("comments"),
214                            nav_menus = [CommentSortMenu(default = sort),
215                                         NumCommentsMenu(article.num_comments,
216                                                         default=num_comments)],
217                            infotext = infotext).render()
218         return res


Specifically, what is the top part of the method doing where there is a @Validate marker?

@validate is validation decorator, used to validate and process parameters from request. You can see its sources at http code.reddit.com/browser/r2/r2/controllers/validator/validator.py#L129

And on the bottom near the return, it is sending objects to the view page. Which viewpage is being called here?

It does not use 'view page', it uses widgets there. LinkInfoPage which contains PaneStack (http code.reddit.com/browser/r2/r2/lib/pages/pages.py#L1317)

So res = LinkInfoPage(...).render() is already generated html, in Pylons response form. It recursively calls .render() on underlying widgets.

P.S. you need to add :// to links, since it does not let to post more than one link.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜