Mercurial > hg > Feedworm
view backend/couchdb/CouchDb.py @ 205:adf7f617bda9
make the name of the design document configurable via command line switch. When cloning the feedworm db, the design document is no longer the same as the database name
author | dirk |
---|---|
date | Sat, 02 Jun 2012 04:24:49 +0200 |
parents | a4832a180c69 |
children | bb3c851b18b1 |
line wrap: on
line source
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"