本文整理汇总了Python中r2.lib.wrapped.Wrapped类的典型用法代码示例。如果您正苦于以下问题:Python Wrapped类的具体用法?Python Wrapped怎么用?Python Wrapped使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Wrapped类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
开发者ID:vin,项目名称:reddit,代码行数:31,代码来源:pages.py
示例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()
开发者ID:Kenneth-Chen,项目名称:lesswrong,代码行数:30,代码来源:pages.py
示例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()
开发者ID:cmak,项目名称:reddit,代码行数:28,代码来源:pages.py
示例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)
开发者ID:donslice,项目名称:reddit,代码行数:7,代码来源:listingcontroller.py
示例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)
开发者ID:PeerInfinity,项目名称:lesswrong,代码行数:7,代码来源:pages.py
示例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
开发者ID:bairyn,项目名称:lesswrong,代码行数:28,代码来源:builder.py
示例7: builder_wrapper
def builder_wrapper(thing):
w = Wrapped(thing)
if isinstance(thing, Link):
w.render_class = InlineArticle
return w
开发者ID:EeroHeikkinen,项目名称:ikaros,代码行数:7,代码来源:listingcontroller.py
示例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
开发者ID:binarycoder,项目名称:reddit-plugin-liveupdate,代码行数:32,代码来源:pages.py
示例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
开发者ID:vin,项目名称:reddit,代码行数:8,代码来源:listingcontroller.py
示例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
开发者ID:PeerInfinity,项目名称:lesswrong,代码行数:9,代码来源:pages.py
示例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
开发者ID:rajbot,项目名称:tikical,代码行数:10,代码来源:things.py
示例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
开发者ID:freekrai,项目名称:reddit,代码行数:10,代码来源:promote.py
示例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
开发者ID:nty-,项目名称:reddit,代码行数:10,代码来源:things.py
示例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
开发者ID:9peppe,项目名称:reddit,代码行数:10,代码来源:things.py
示例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)
开发者ID:DFectuoso,项目名称:culter,代码行数:12,代码来源:listingcontroller.py
示例16: builder_wrapper
def builder_wrapper(thing):
if isinstance(thing, Comment):
f = thing._fullname
w = Wrapped(thing)
w.render_class = Message
w.to_id = c.user._id
w.was_comment = True
w._fullname = f
else:
w = ListingController.builder_wrapper(thing)
return w
开发者ID:aburan28,项目名称:reddit,代码行数:12,代码来源:listingcontroller.py
示例17: __init__
def __init__(self, *args, **kwargs):
from r2.lib.user_stats import top_users
uids = top_users()
# Returns a hash keyed in the uid
users = Account._byID(uids, data=True)
# Retrieve the Account objects in this way to preseve the sort order
all_users = (users[u] for u in uids)
# Filter out banned and spammy accounts
self.things = filter(lambda user: not c.site.is_banned(user) and user.spammer < 1, all_users)
Wrapped.__init__(self, *args, **kwargs)
开发者ID:EmileKroeger,项目名称:lesswrong,代码行数:12,代码来源:pages.py
示例18: editable_add_props
def editable_add_props(l):
if not isinstance(l, Wrapped):
l = Wrapped(l)
l.bids = get_transactions(l)
campaigns = {}
for campaign in PromoCampaign._by_link(l._id):
campaigns[campaign._id] = RenderableCampaign(l, campaign, l.bids.get(campaign._id))
l.campaigns = campaigns
return l
开发者ID:jianbin91,项目名称:reddit,代码行数:12,代码来源:promote.py
示例19: builder_wrapper
def builder_wrapper(thing):
if isinstance(thing, Comment):
p = thing.permalink
f = thing._fullname
thing.__class__ = Message
w = Wrapped(thing)
w.to_id = c.user._id
w.subject = 'comment reply'
w.was_comment = True
w.permalink, w._fullname = p, f
return w
else:
return ListingController.builder_wrapper(thing)
开发者ID:cmak,项目名称:reddit,代码行数:13,代码来源:listingcontroller.py
示例20: ajax_render
def ajax_render(self, style="html"):
"""Generates a 'rendering' of this item suitable for
processing by JS for insert or removal from an existing
UserList"""
cells = []
for cell in self.cells:
r = Wrapped.part_render(self, 'cell_type', cell)
cells.append(spaceCompress(r))
return dict(cells=cells, id=self.type, name=self.name)
开发者ID:vin,项目名称:reddit,代码行数:9,代码来源:pages.py
注:本文中的r2.lib.wrapped.Wrapped类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论