comparison 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
comparison
equal deleted inserted replaced
179:c8393c2cd324 180:a4832a180c69
1 1
2 from argparse import ArgumentParser 2 from argparse import ArgumentParser
3 3
4 database_url = None
4 database = "feedworm" 5 database = "feedworm"
5 6
6 def init(): 7 def init():
8 args = _parseArguments()
9 _setDatabaseName(args)
10 _setDatabaseUrl(args)
11
12 def _parseArguments():
7 parser = ArgumentParser() 13 parser = ArgumentParser()
8 parser.add_argument("--dbname", nargs="?", help="Name of the database") 14 parser.add_argument("--dbname", nargs="?", help="Name of the database")
9 args = parser.parse_known_args() 15 parser.add_argument("--dburl", nargs="?", help="URL of the database")
16 return parser.parse_known_args()
17
18 def _setDatabaseName(args):
10 dbname = args[0].dbname 19 dbname = args[0].dbname
11 if dbname is not None: 20 if dbname is not None:
12 global database 21 global database
13 database = dbname 22 database = dbname
23
24 def _setDatabaseUrl(args):
25 dburl = args[0].dburl
26 if dburl is not None:
27 global database_url
28 database_url = dburl
14 29
15 # 30 #
16 # accessor methods for the various views 31 # accessor methods for the various views
17 # 32 #
18 33