Mercurial > hg > Feedworm
annotate backend/couchdb/CouchDb.py @ 178:e8cc86981938
default DB name is feedworm, fix setting the dbname via commandline parameter
author | dirk |
---|---|
date | Sat, 10 Sep 2011 04:26:13 +0200 |
parents | 57e324fa4350 |
children | a4832a180c69 |
rev | line source |
---|---|
169
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
1 |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
2 from argparse import ArgumentParser |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
3 |
178
e8cc86981938
default DB name is feedworm, fix setting the dbname via commandline parameter
dirk
parents:
175
diff
changeset
|
4 database = "feedworm" |
169
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
5 |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
6 def init(): |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
7 parser = ArgumentParser() |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
8 parser.add_argument("--dbname", nargs="?", help="Name of the database") |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
9 args = parser.parse_known_args() |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
10 dbname = args[0].dbname |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
11 if dbname is not None: |
178
e8cc86981938
default DB name is feedworm, fix setting the dbname via commandline parameter
dirk
parents:
175
diff
changeset
|
12 global database |
169
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
13 database = dbname |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
14 |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
15 # |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
16 # accessor methods for the various views |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
17 # |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
18 |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
19 def feedEntriesByFeed(): |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
20 return database + "/feedEntries_by_feed" |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
21 |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
22 def unreadFeedEntriesByFeed(): |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
23 return database + "/unread_feedEntries_by_feed" |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
24 |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
25 def feeds(): |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
26 return database + "/feeds" |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
27 |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
28 def feedEntryByLink(): |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
29 return database + "/feedEntry_by_link" |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
30 |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
31 def preference(): |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
32 return database + "/preference" |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
33 |
174 | 34 def readFeedEntriesByCreateDate(): |
35 return database + "/read_feedEntries_by_create_date" | |
169
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
36 |
175
57e324fa4350
implement getting a list of feeds that have unread entries
dirk
parents:
174
diff
changeset
|
37 def feedsWithUnreadEntries(): |
57e324fa4350
implement getting a list of feeds that have unread entries
dirk
parents:
174
diff
changeset
|
38 return database + "/feeds_with_unread_entries" |