view backend/couchdb/CouchDb.py @ 236:c5250fcc3881

remove a workaround along with its wrong explanation
author Dirk Olmes <dirk@xanthippe.ping.de>
date Mon, 26 Jan 2015 13:43:38 +0100
parents bb3c851b18b1
children
line wrap: on
line source

# -*- coding: utf-8 -*-
from argparse import ArgumentParser

database_url = None
database = "feedworm"
design_document = database

def init():
    args = _parseArguments()
    _setDatabaseName(args)
    _setDatabaseUrl(args)
    _setDesignDocument(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")
    parser.add_argument("--designdoc", nargs="?", help="name of the feedworm design document")
    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

def _setDesignDocument(args):
    designDocument = args[0].designdoc
    if designDocument is not None:
        global design_document
        design_document = designDocument

#
# accessor methods for the various views
#

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

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

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

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

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

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

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