def get_list_for(db, participant_id):
 if (participant_id is None):
  return db.all('\n            SELECT c.*\n              FROM communities c\n          ORDER BY nmembers DESC, slug\n        ')
 else:
  return db.all('\n            SELECT c.*\n              FROM current_community_members ccm\n              JOIN communities c ON c.slug = ccm.slug\n             WHERE ccm.is_member AND ccm.participant = %s\n          ORDER BY c.nmembers ASC, c.slug\n        ', (participant_id,))

def get_list_for ( db , participant_id ) : if ( participant_id is None ) : return db . all ( '\n            SELECT c.*\n              FROM communities c\n          ORDER BY nmembers DESC, slug\n        ' ) else : return db . all ( '\n            SELECT c.*\n              FROM current_community_members ccm\n              JOIN communities c ON c.slug = ccm.slug\n             WHERE ccm.is_member AND ccm.participant = %s\n          ORDER BY c.nmembers ASC, c.slug\n        ' , ( participant_id , ) )
return a listing of communities .