Mercurial > hg > Feedworm
comparison 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 |
comparison
equal
deleted
inserted
replaced
204:4cb22b47b659 | 205:adf7f617bda9 |
---|---|
1 | 1 |
2 from argparse import ArgumentParser | 2 from argparse import ArgumentParser |
3 | 3 |
4 database_url = None | 4 database_url = None |
5 database = "feedworm" | 5 database = "feedworm" |
6 design_document = database | |
6 | 7 |
7 def init(): | 8 def init(): |
8 args = _parseArguments() | 9 args = _parseArguments() |
9 _setDatabaseName(args) | 10 _setDatabaseName(args) |
10 _setDatabaseUrl(args) | 11 _setDatabaseUrl(args) |
12 _setDesignDocument(args) | |
11 | 13 |
12 def _parseArguments(): | 14 def _parseArguments(): |
13 parser = ArgumentParser() | 15 parser = ArgumentParser() |
14 parser.add_argument("--dbname", nargs="?", help="Name of the database") | 16 parser.add_argument("--dbname", nargs="?", help="Name of the database") |
15 parser.add_argument("--dburl", nargs="?", help="URL of the database") | 17 parser.add_argument("--dburl", nargs="?", help="URL of the database") |
18 parser.add_argument("--designdoc", nargs="?", help="name of the feedworm design document") | |
16 return parser.parse_known_args() | 19 return parser.parse_known_args() |
17 | 20 |
18 def _setDatabaseName(args): | 21 def _setDatabaseName(args): |
19 dbname = args[0].dbname | 22 dbname = args[0].dbname |
20 if dbname is not None: | 23 if dbname is not None: |
25 dburl = args[0].dburl | 28 dburl = args[0].dburl |
26 if dburl is not None: | 29 if dburl is not None: |
27 global database_url | 30 global database_url |
28 database_url = dburl | 31 database_url = dburl |
29 | 32 |
33 def _setDesignDocument(args): | |
34 designDocument = args[0].designdoc | |
35 if designDocument is not None: | |
36 global design_document | |
37 design_document = designDocument | |
38 | |
30 # | 39 # |
31 # accessor methods for the various views | 40 # accessor methods for the various views |
32 # | 41 # |
33 | 42 |
34 def feedEntriesByFeed(): | 43 def feedEntriesByFeed(): |
35 return database + "/feedEntries_by_feed" | 44 return design_document + "/feedEntries_by_feed" |
36 | 45 |
37 def unreadFeedEntriesByFeed(): | 46 def unreadFeedEntriesByFeed(): |
38 return database + "/unread_feedEntries_by_feed" | 47 return design_document + "/unread_feedEntries_by_feed" |
39 | 48 |
40 def feeds(): | 49 def feeds(): |
41 return database + "/feeds" | 50 return design_document + "/feeds" |
42 | 51 |
43 def feedEntryByLink(): | 52 def feedEntryByLink(): |
44 return database + "/feedEntry_by_link" | 53 return design_document + "/feedEntry_by_link" |
45 | 54 |
46 def preference(): | 55 def preference(): |
47 return database + "/preference" | 56 return design_document + "/preference" |
48 | 57 |
49 def readFeedEntriesByCreateDate(): | 58 def readFeedEntriesByCreateDate(): |
50 return database + "/read_feedEntries_by_create_date" | 59 return design_document + "/read_feedEntries_by_create_date" |
51 | 60 |
52 def feedsWithUnreadEntries(): | 61 def feedsWithUnreadEntries(): |
53 return database + "/feeds_with_unread_entries" | 62 return design_document + "/feeds_with_unread_entries" |