repair caching bug related to widget with votable buttons; add over18 parameter to subreddit json

This commit is contained in:
KeyserSosa
2009-07-09 16:51:30 -07:00
parent eac94f7705
commit c034fe485b
6 changed files with 9 additions and 6 deletions

View File

@@ -94,6 +94,8 @@ class ButtonsController(RedditController):
css != 'http://www.wired.com/css/redditsocial.css'):
css = None
if link:
url = link.url
wrapper = make_wrapper(Button if vote else ButtonNoBody,
url = url,
target = "_new" if newwindow else "_parent",

View File

@@ -182,6 +182,7 @@ class SubredditJsonTemplate(ThingJsonTemplate):
_data_attrs_ = ThingJsonTemplate.data_attrs(subscribers = "score",
title = "title",
url = "path",
over18 = "over_18",
description = "description")
class LinkJsonTemplate(ThingJsonTemplate):

View File

@@ -109,16 +109,15 @@ class MessageButtons(PrintableButtons):
# formerly ListingController.builder_wrapper
def default_thing_wrapper(**params):
style = params.get('style', c.render_style)
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
params['parent_wrapper'] = _default_thing_wrapper
return make_wrapper(**params)

View File

@@ -410,8 +410,9 @@ class Wrapped(CachedTemplate):
if self.cachable:
for i, l in enumerate(self.lookups):
if hasattr(l, "wrapped_cache_key"):
# setattr will force a __dict__ entry
setattr(self, "_lookup%d_cache_key" % i,
# setattr will force a __dict__ entry, but only if the
# param doesn't start with "_"
setattr(self, "lookup%d_cache_key" % i,
''.join(map(repr,
l.wrapped_cache_key(self, style))))
return CachedTemplate.cache_key(self, attr, style)

View File

@@ -55,6 +55,7 @@ class Link(Thing, Printable):
selftext = '',
ip = '0.0.0.0')
def __init__(self, *a, **kw):
Thing.__init__(self, *a, **kw)

View File

@@ -28,7 +28,6 @@ class Printable(object):
can_ban = False
deleted = False
rowstyle = 'even'
reported = False
collapsed = False
author = None
margin = 0
@@ -75,7 +74,7 @@ class Printable(object):
@staticmethod
def wrapped_cache_key(wrapped, style):
s = [wrapped._fullname, wrapped._spam]
s = [wrapped._fullname, wrapped._spam, wrapped.reported]
if style == 'htmllite':
s.extend([c.bgcolor, c.bordercolor,