From 446cf53d8fef63a0c4503f8389c5c26a41d3875f Mon Sep 17 00:00:00 2001 From: cedric Date: Fri, 29 Jan 2010 21:09:46 +0100 Subject: Initial import --- pyAggr3g470r.py | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 pyAggr3g470r.py (limited to 'pyAggr3g470r.py') diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py new file mode 100644 index 00000000..db4ac620 --- /dev/null +++ b/pyAggr3g470r.py @@ -0,0 +1,84 @@ +#! /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 = """ 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 += """
""" + + + 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 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 + + + +if __name__ == '__main__': + root = Root() + cherrypy.quickstart(root, config=path) \ No newline at end of file -- cgit