#! /usr/local/bin/python #-*- coding: utf-8 -*- __author__ = "Cedric Bonhomme" __version__ = "$Revision: 0.1 $" __date__ = "$Date: 2010/29/01 $" __copyright__ = "Copyright (c) 2010 Cedric Bonhomme" __license__ = "GPLv3" import sqlite3 import cherrypy import ConfigParser from cherrypy.lib.static import serve_file config = ConfigParser.RawConfigParser() config.read("./cfg/pyAggr3g470r.cfg") path = config.get('global','path') bindhost = "0.0.0.0" cherrypy.config.update({ 'server.socket_port': 12556, 'server.socket_host': bindhost}) path = { '/css/style.css': {'tools.staticfile.on': True, 'tools.staticfile.filename':path+'css/style.css'} } htmlheader = """\n\n\n\n pyAggr3g470r - RSS Feed Reader """ htmlfooter = """""" htmlnav = """

pyAggr3g470r - RSS Feed Reader

pyAggr3g470r (source code) """ class Root: def index(self): html = htmlheader html += htmlnav html += """
""" html += """

Search

""" html += """
""" html += """Management of feed""" html += """
""" dic = self.retrieve_feed() for rss_feed in dic.keys(): html += '

' + dic[rss_feed][0][1].encode('utf-8') + "

" for article in dic[rss_feed]: html += '' + article[2].encode('utf-8') + "
" html += htmlfooter return html def f(self): """ """ return "Hello world !" def retrieve_feed(self): conn = sqlite3.connect("./var/feed.db", isolation_level = None) c = conn.cursor() list_of_articles = c.execute("SELECT * FROM rss_feed").fetchall() c.close() dic = {} for article in list_of_articles: if article[2] not in dic: dic[article[2]] = [(article[0], article[1], article[3], article[4])] else: dic[article[2]].append((article[0], article[1], article[3], article[4])) return dic index.exposed = True f.exposed = True if __name__ == '__main__': root = Root() cherrypy.quickstart(root, config=path)