view backend/couchdb/CouchDb.py @ 201:50b578588405

method ordering
author dirk
date Wed, 01 Feb 2012 01:26:09 +0100
parents a4832a180c69
children adf7f617bda9
line wrap: on
line source


from argparse import ArgumentParser

database_url = None
database = "feedworm"

def init():
    args = _parseArguments()
    _setDatabaseName(args)
    _setDatabaseUrl(args)

def _parseArguments():
    parser = ArgumentParser()
    parser.add_argument("--dbname", nargs="?", help="Name of the database")
    parser.add_argument("--dburl", nargs="?", help="URL of the database")
    return parser.parse_known_args()

def _setDatabaseName(args):
    dbname = args[0].dbname
    if dbname is not None:
        global database
        database = dbname

def _setDatabaseUrl(args):
    dburl = args[0].dburl
    if dburl is not None:
        global database_url
        database_url = dburl

#
# accessor methods for the various views
#

def feedEntriesByFeed():
    return database + "/feedEntries_by_feed"

def unreadFeedEntriesByFeed():
    return database + "/unread_feedEntries_by_feed"

def feeds():
    return database + "/feeds"

def feedEntryByLink():
    return database + "/feedEntry_by_link"

def preference():
    return database + "/preference"

def readFeedEntriesByCreateDate():
    return database + "/read_feedEntries_by_create_date"

def feedsWithUnreadEntries():
    return database + "/feeds_with_unread_entries"