Mercurial > hg > Feedworm
diff backend/couchdb/CouchDb.py @ 180:a4832a180c69
allow setting the URL to the database via command line
author | dirk |
---|---|
date | Sat, 10 Sep 2011 04:43:40 +0200 |
parents | e8cc86981938 |
children | adf7f617bda9 |
line wrap: on
line diff
--- a/backend/couchdb/CouchDb.py Sat Sep 10 04:32:53 2011 +0200 +++ b/backend/couchdb/CouchDb.py Sat Sep 10 04:43:40 2011 +0200 @@ -1,17 +1,32 @@ 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") - args = parser.parse_known_args() + 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 #