def getTopicUrl(t_id): cursor = db.conn.cursor() cursor.execute("""SELECT forums.name, topics.title, forums.f_id, t_id FROM topics, forums WHERE topics.f_id=forums.f_id and t_id=%s""", (t_id,)) assert cursor.rowcount <= 1 if cursor.rowcount == 0: return '/forums/' else: row = cursor.fetchone() return '/%s-%i/%s-%i/' % (render.getUrlPrettyName(row[0]), row[2], render.getUrlPrettyName(row[1]), row[3])
def getForumUrl(f_id): cursor = db.conn.cursor() cursor.execute("SELECT forums.name, f_id FROM forums WHERE f_id=%s", (f_id,)) assert cursor.rowcount <= 1 if cursor.rowcount == 0: return '/forums/' else: row = cursor.fetchone() return '/%s-%i/' % (render.getUrlPrettyName(row[0]), row[1])
def fullList(conditions): torrents= db.conn.cursor() torrents.execute(""" SELECT t_id, torrents.name, torrents.description, license, categories.name FROM torrents INNER JOIN categories USING (c_id) """ + conditions) rows = '' for torrent in torrents: rows += fullListRowTemplate % { 'name_in_url': render.getUrlPrettyName(torrent[1]), 'id': torrent[0], 'name': torrent[1], 'description': render.torrentDescription(torrent[2]), 'license': torrent[3], 'category': torrent[4]} return fullListBodyTemplate % rows
def details(t_id): torrent = db.conn.cursor() torrent.execute(""" SELECT t_id, torrents.name, torrents.description, license, categories.name INNER JOIN categories USING (c_id) WHERE t_id=%s""", (t_id,)) if torrent.rowcount == 0: raise exceptions.Error404() assert torrent.rowcount == 1 torrent = torrent.fetchone() return detailsTemplate % { 'name_in_url': render.getUrlPrettyName(torrent[1]), 'id': torrent[0], 'name': torrent[1], 'description': render.torrentDescription(torrent[2]), 'license': torrent[3], 'category': torrent[4]}