def run_new_comments(limit=1000):
 @g.stats.amqp_processor('newcomments_q')
 def _run_new_comments(msgs, chan):
  fnames = [msg.body for msg in msgs]
  comments = Comment._by_fullname(fnames, data=True, return_dict=False)
  add_queries([get_all_comments()], insert_items=comments)
  bysrid = _by_srid(comments, False)
  for (srid, sr_comments) in bysrid.iteritems():
   add_queries([_get_sr_comments(srid)], insert_items=sr_comments)
 amqp.handle_items('newcomments_q', _run_new_comments, limit=limit)

def run_new_comments ( limit = 1000 ) : @ g . stats . amqp_processor ( 'newcomments_q' ) def _run_new_comments ( msgs , chan ) : fnames = [ msg . body for msg in msgs ] comments = Comment . _by_fullname ( fnames , data = True , return_dict = False ) add_queries ( [ get_all_comments ( ) ] , insert_items = comments ) bysrid = _by_srid ( comments , False ) for ( srid , sr_comments ) in bysrid . iteritems ( ) : add_queries ( [ _get_sr_comments ( srid ) ] , insert_items = sr_comments ) amqp . handle_items ( 'newcomments_q' , _run_new_comments , limit = limit )
add new incoming comments to the /comments page .