tornado: Send rendered messages to Tornado via memcached.

(imported from commit c1e8a017fa61b4e3f5c44ad4e5f59e4faf012ca3)
This commit is contained in:
Tim Abbott
2013-01-10 15:08:02 -05:00
parent a058471a56
commit e36fd4b817
3 changed files with 5 additions and 20 deletions

View File

@@ -150,14 +150,14 @@ def do_send_message(message, no_log=False):
# We can only publish messages to longpolling clients if the Tornado server is running.
if settings.TORNADO_SERVER:
# Render Markdown etc. here, so that the single-threaded Tornado server doesn't have to.
# TODO: Reduce duplication in what we send.
rendered = { 'text/html': message.to_dict(apply_markdown=True),
'text/x-markdown': message.to_dict(apply_markdown=False) }
# Render Markdown etc. here and store (automatically) in
# memcached, so that the single-threaded Tornado server
# doesn't have to.
message.to_dict(apply_markdown=True)
message.to_dict(apply_markdown=False)
requests.post(settings.TORNADO_SERVER + '/notify_new_message', data=dict(
secret = settings.SHARED_SECRET,
message = message.id,
rendered = simplejson.dumps(rendered),
users = simplejson.dumps([str(user.id) for user in recipients])))
def create_stream_if_needed(realm, stream_name):