# HG changeset patch # User Dirk Olmes # Date 1273810565 -7200 # Node ID 22214d79ed4196bf773146ffd20e24e1cc10bb0e # Parent 74b8c9a9d5de9dfb7398d87e1186e0b3fd983f9e database URL must be given as commandline argument now, no need for creating complicated config files. Add a menu entry for opening the selected article in browser. diff -r 74b8c9a9d5de -r 22214d79ed41 Database.py --- a/Database.py Wed May 05 03:10:15 2010 +0200 +++ b/Database.py Fri May 14 06:16:05 2010 +0200 @@ -2,7 +2,7 @@ import Mapping import sqlalchemy import sqlalchemy.orm -import util +import sys # Keep the connection to the database only once. The feed updater and the GUI app will # operate on a single engine/session but this comes in handy for interactive use @@ -10,16 +10,22 @@ SessionMaker = None def createSession(): - databaseUrl = util.loadDatabaseUrl() + databaseUrl = _getDatabaseUrl() initEngine(databaseUrl) Mapping.createMapping(engine) initSessionMaker() return SessionMaker() +def _getDatabaseUrl(): + if len(sys.argv) < 2: + print("Usage: %s " % (sys.argv[0])) + sys.exit(1) + return sys.argv[1] + def initEngine(databaseUrl): global engine if engine is None: - engine = sqlalchemy.create_engine(databaseUrl, echo=False) + engine = sqlalchemy.create_engine(databaseUrl, echo=True) def initSessionMaker(): global SessionMaker diff -r 74b8c9a9d5de -r 22214d79ed41 MainWindow.py --- a/MainWindow.py Wed May 05 03:10:15 2010 +0200 +++ b/MainWindow.py Fri May 14 06:16:05 2010 +0200 @@ -8,6 +8,7 @@ from PyQt4.QtGui import QFont from Ui_MainWindow import Ui_MainWindow import FeedUpdater +import subprocess class MainWindow(QtGui.QMainWindow): def __init__(self, session=None): @@ -55,6 +56,11 @@ # TODO get status from feedUpdater and display in status area of the main window self.updateFeedList() + def openSelectedEntry(self): + # TODO make browser configurable + browser = "/usr/local/bin/opera" + subprocess.Popen([browser, self.selectedEntry.link]) + class FeedEntryItemDelegate(QtGui.QStyledItemDelegate): def __init__(self): QtGui.QStyledItemDelegate.__init__(self, None) diff -r 74b8c9a9d5de -r 22214d79ed41 Ui_MainWindow.ui --- a/Ui_MainWindow.ui Wed May 05 03:10:15 2010 +0200 +++ b/Ui_MainWindow.ui Fri May 14 06:16:05 2010 +0200 @@ -71,6 +71,7 @@ Article + @@ -105,6 +106,14 @@ M + + + Open in browser + + + Ctrl+O + + @@ -195,11 +204,28 @@ + + actionOpenInBrowser + activated() + MainWindow + openSelectedEntry() + + + -1 + -1 + + + 495 + 374 + + + addFeed() feedSelected(QModelIndex) feedEntrySelected(QModelIndex) toggleReadOnSelectedEntry() + openSelectedEntry() diff -r 74b8c9a9d5de -r 22214d79ed41 database-cassiopeia.ini --- a/database-cassiopeia.ini Wed May 05 03:10:15 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ - -[database] -url = sqlite:///feedworm.sqlite diff -r 74b8c9a9d5de -r 22214d79ed41 util.py --- a/util.py Wed May 05 03:10:15 2010 +0200 +++ b/util.py Fri May 14 06:16:05 2010 +0200 @@ -1,9 +1,7 @@ -from ConfigParser import ConfigParser from datetime import datetime, timedelta from Feed import Feed import logging -import socket logger = logging.getLogger("database") @@ -12,15 +10,6 @@ logging.getLogger("sqlalchemy").setLevel(logging.INFO) logging.getLogger("sqlalchemy.orm").setLevel(logging.WARN) -def loadDatabaseUrl(): - hostname = socket.gethostname() - filename = "database-%s.ini" % hostname - logger.debug("loading database configuration from " + filename) - - parser = ConfigParser(); - parser.read(filename) - return parser.get("database", "url") - def loadFeeds(session=None, filename="feeds.txt"): file = open(filename) for line in file: