本文整理汇总了Python中r2.lib.wrapped.Wrapped类的典型用法代码示例。如果您正苦于以下问题:Python Wrapped类的具体用法?Python Wrapped怎么用?Python Wrapped使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Wrapped类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, space_compress = True, nav_menus = None, loginbox = True,
infotext = '', content = None, title = '', robots = None,
show_sidebar = True, **context):
Wrapped.__init__(self, **context)
self.title = title
self.robots = robots
self.infotext = infotext
self.loginbox = True
self.show_sidebar = show_sidebar
self.space_compress = space_compress
#put the sort menus at the top
self.nav_menu = MenuArea(menus = nav_menus) if nav_menus else None
#add the infobar
self.infobar = None
if c.firsttime and c.site.firsttext and not infotext:
infotext = c.site.firsttext
if infotext:
self.infobar = InfoBar(message = infotext)
self.srtopbar = None
if not c.cname:
self.srtopbar = SubredditTopBar()
if c.user_is_loggedin and self.show_sidebar:
self._content = PaneStack([ShareLink(), content])
else:
self._content = content
self.toolbars = self.build_toolbars()
示例2: __init__
def __init__(self, space_compress = True, nav_menus = None, loginbox = True,
infotext = '', content = None, title = '', robots = None,
show_sidebar = True, body_class = None, **context):
Wrapped.__init__(self, **context)
self.title = title
self.robots = robots
self.infotext = infotext
self.loginbox = True
self.show_sidebar = show_sidebar
self.space_compress = space_compress
self.body_class = body_class
#put the sort menus at the top
self.nav_menu = MenuArea(menus = nav_menus) if nav_menus else None
#add the infobar
self.infobar = None
if c.firsttime and c.site.firsttext and not infotext:
infotext = c.site.firsttext
if not infotext and hasattr(c.site, 'infotext'):
infotext = c.site.infotext
if infotext:
self.infobar = InfoBar(message = infotext)
self.srtopbar = None
if not c.cname:
self.srtopbar = SubredditTopBar()
self._content = content
self.toolbars = self.build_toolbars()
示例3: __init__
def __init__(self, space_compress = True, nav_menus = None, loginbox = True,
infotext = '', content = None, title = '', show_sidebar = True,
**context):
Wrapped.__init__(self, **context)
self.title = title
self.infotext = infotext
self.loginbox = True
self.show_sidebar = show_sidebar
self.space_compress = space_compress
#put the sort menus at the top
self.nav_menu = MenuArea(menus = nav_menus) if nav_menus else None
#add the infobar
self.infobar = None
if c.firsttime and c.site.firsttext and not infotext:
infotext = c.site.firsttext
if infotext:
self.infobar = InfoBar(message = infotext)
#c.subredditbox is set by VSRMask
self.subreddit_sidebox = False
if c.subreddit_sidebox:
self.subreddit_sidebox = True
self.subreddit_checkboxes = c.site == Default
self._content = content
self.toolbars = self.build_toolbars()
示例4: trial_wrap
def trial_wrap(item):
if item is trial:
w = Wrapped(item)
w.trial_mode = True
w.render_class = LinkOnTrial
return w
return self.builder_wrapper(item)
示例5: __init__
def __init__(self, sr = None, link = None, listing = '',
timedeltatext = '', *a, **kw):
Wrapped.__init__(self, sr = sr, link = link,
datefmt = datefmt,
timedeltatext = timedeltatext,
listing = listing,
*a, **kw)
示例6: context_from_comment
def context_from_comment(self, comment):
if isinstance(comment, Comment):
link = Link._byID(comment.link_id)
wrapped, = self.wrap_items((comment,))
# If there are any child comments, add an expand link
children = list(Comment._query(Comment.c.parent_id == comment._id))
if children:
more = Wrapped(MoreChildren(link, 0))
more.children.extend(children)
more.count = len(children)
wrapped.child = self.empty_listing()
wrapped.child.things.append(more)
# If there's a parent comment, surround the child comment with it
parent_id = getattr(comment, 'parent_id', None)
if parent_id is not None:
parent_comment = Comment._byID(parent_id)
if parent_comment:
parent_wrapped, = self.wrap_items((parent_comment,))
parent_wrapped.child = self.empty_listing()
parent_wrapped.child.things.append(wrapped)
wrapped = parent_wrapped
wrapped.show_response_to = True
else:
wrapped, = self.wrap_items((comment,))
return wrapped
示例7: builder_wrapper
def builder_wrapper(thing):
w = Wrapped(thing)
if isinstance(thing, Link):
w.render_class = InlineArticle
return w
示例8: get_links
def get_links(cls, event_id):
link_ids = cls._get_related_link_ids(event_id)
links = Link._byID(link_ids, data=True, return_dict=False)
links.sort(key=lambda L: L.num_comments, reverse=True)
sr_ids = set(L.sr_id for L in links)
subreddits = Subreddit._byID(sr_ids, data=True)
wrapped = []
for link in links:
w = Wrapped(link)
if w._spam or w._deleted:
continue
if not getattr(w, "allow_liveupdate", True):
continue
w.subreddit = subreddits[link.sr_id]
# ideally we'd check if the user can see the subreddit, but by
# doing this we keep everything user unspecific which makes caching
# easier.
if w.subreddit.type == "private":
continue
comment_label = ungettext("comment", "comments", link.num_comments)
w.comments_label = strings.number_label % dict(
num=link.num_comments, thing=comment_label)
wrapped.append(w)
return wrapped
示例9: builder_wrapper
def builder_wrapper(thing):
w = Wrapped(thing)
if c.user.pref_compress and isinstance(thing, Link):
w.render_class = LinkCompressed
w.score_fmt = Score.points
return w
示例10: wrap_thing
def wrap_thing(thing):
w = Wrapped(thing)
if isinstance(thing, Link):
w.render_class = InlineArticle
elif isinstance(thing, Comment):
w.render_class = InlineComment
return w
示例11: _default_thing_wrapper
def _default_thing_wrapper(thing):
w = Wrapped(thing)
style = params.get("style", c.render_style)
if isinstance(thing, Link):
if thing.promoted:
w.render_class = PromotedLink
w.rowstyle = "promoted link"
elif style == "htmllite":
w.score_fmt = Score.points
return w
示例12: editable_add_props
def editable_add_props(l):
if not isinstance(l, Wrapped):
l = Wrapped(l)
l.bids = get_transactions(l)
l.campaigns = dict((indx, RenderableCampaign(l, indx, campaign, l.bids.get(indx)))
for indx, campaign in
getattr(l, "campaigns", {}).iteritems())
return l
示例13: _default_thing_wrapper
def _default_thing_wrapper(thing):
w = Wrapped(thing)
style = params.get('style', c.render_style)
if isinstance(thing, Link):
if thing.promoted is not None:
w.render_class = PromotedLink
elif style == 'htmllite':
w.score_fmt = Score.safepoints
w.should_incr_counts = style != 'htmllite'
return w
示例14: _default_thing_wrapper
def _default_thing_wrapper(thing):
w = Wrapped(thing)
style = params.get('style', c.render_style)
if isinstance(thing, Link):
if thing.promoted is not None:
w.render_class = PromotedLink
w.rowstyle = 'promoted link'
elif style == 'htmllite':
w.score_fmt = Score.points
return w
示例15: builder_wrapper
def builder_wrapper(thing):
if isinstance(thing, Comment):
p = thing.make_permalink_slow()
f = thing._fullname
w = Wrapped(thing)
w.render_class = Message
w.to_id = c.user._id
w.was_comment = True
w.permalink, w._fullname = p, f
return w
else:
return ListingController.builder_wrapper(thing)