views:

73

answers:

1

I'm trying to understand 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
+2  A: 

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.

Daniel Kluev