Mercurial > hg > Feedworm
annotate backend/couchdb/CouchDb.py @ 216:9bc4b2465435
change the hardcoded browser
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Sun, 27 Apr 2014 05:19:45 +0200 |
parents | adf7f617bda9 |
children | bb3c851b18b1 |
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 |
180
a4832a180c69
allow setting the URL to the database via command line
dirk
parents:
178
diff
changeset
|
4 database_url = None |
178
e8cc86981938
default DB name is feedworm, fix setting the dbname via commandline parameter
dirk
parents:
175
diff
changeset
|
5 database = "feedworm" |
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
dirk
parents:
180
diff
changeset
|
6 design_document = database |
169
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
7 |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
8 def init(): |
180
a4832a180c69
allow setting the URL to the database via command line
dirk
parents:
178
diff
changeset
|
9 args = _parseArguments() |
a4832a180c69
allow setting the URL to the database via command line
dirk
parents:
178
diff
changeset
|
10 _setDatabaseName(args) |
a4832a180c69
allow setting the URL to the database via command line
dirk
parents:
178
diff
changeset
|
11 _setDatabaseUrl(args) |
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
dirk
parents:
180
diff
changeset
|
12 _setDesignDocument(args) |
180
a4832a180c69
allow setting the URL to the database via command line
dirk
parents:
178
diff
changeset
|
13 |
a4832a180c69
allow setting the URL to the database via command line
dirk
parents:
178
diff
changeset
|
14 def _parseArguments(): |
169
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
15 parser = ArgumentParser() |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
16 parser.add_argument("--dbname", nargs="?", help="Name of the database") |
180
a4832a180c69
allow setting the URL to the database via command line
dirk
parents:
178
diff
changeset
|
17 parser.add_argument("--dburl", nargs="?", help="URL of the database") |
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
dirk
parents:
180
diff
changeset
|
18 parser.add_argument("--designdoc", nargs="?", help="name of the feedworm design document") |
180
a4832a180c69
allow setting the URL to the database via command line
dirk
parents:
178
diff
changeset
|
19 return parser.parse_known_args() |
a4832a180c69
allow setting the URL to the database via command line
dirk
parents:
178
diff
changeset
|
20 |
a4832a180c69
allow setting the URL to the database via command line
dirk
parents:
178
diff
changeset
|
21 def _setDatabaseName(args): |
169
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
22 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
|
23 if dbname is not None: |
178
e8cc86981938
default DB name is feedworm, fix setting the dbname via commandline parameter
dirk
parents:
175
diff
changeset
|
24 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
|
25 database = dbname |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
26 |
180
a4832a180c69
allow setting the URL to the database via command line
dirk
parents:
178
diff
changeset
|
27 def _setDatabaseUrl(args): |
a4832a180c69
allow setting the URL to the database via command line
dirk
parents:
178
diff
changeset
|
28 dburl = args[0].dburl |
a4832a180c69
allow setting the URL to the database via command line
dirk
parents:
178
diff
changeset
|
29 if dburl is not None: |
a4832a180c69
allow setting the URL to the database via command line
dirk
parents:
178
diff
changeset
|
30 global database_url |
a4832a180c69
allow setting the URL to the database via command line
dirk
parents:
178
diff
changeset
|
31 database_url = dburl |
a4832a180c69
allow setting the URL to the database via command line
dirk
parents:
178
diff
changeset
|
32 |
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
dirk
parents:
180
diff
changeset
|
33 def _setDesignDocument(args): |
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
dirk
parents:
180
diff
changeset
|
34 designDocument = args[0].designdoc |
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
dirk
parents:
180
diff
changeset
|
35 if designDocument is not None: |
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
dirk
parents:
180
diff
changeset
|
36 global design_document |
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
dirk
parents:
180
diff
changeset
|
37 design_document = designDocument |
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
dirk
parents:
180
diff
changeset
|
38 |
169
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
39 # |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
40 # 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
|
41 # |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
42 |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
43 def feedEntriesByFeed(): |
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
dirk
parents:
180
diff
changeset
|
44 return design_document + "/feedEntries_by_feed" |
169
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
45 |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
46 def unreadFeedEntriesByFeed(): |
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
dirk
parents:
180
diff
changeset
|
47 return design_document + "/unread_feedEntries_by_feed" |
169
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
48 |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
49 def feeds(): |
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
dirk
parents:
180
diff
changeset
|
50 return design_document + "/feeds" |
169
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
51 |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
52 def feedEntryByLink(): |
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
dirk
parents:
180
diff
changeset
|
53 return design_document + "/feedEntry_by_link" |
169
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
54 |
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
55 def preference(): |
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
dirk
parents:
180
diff
changeset
|
56 return design_document + "/preference" |
169
91a24f499318
introdue an abstraction for the name of the database so it can be changed via commandline parameter
dirk
parents:
diff
changeset
|
57 |
174 | 58 def readFeedEntriesByCreateDate(): |
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
dirk
parents:
180
diff
changeset
|
59 return design_document + "/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
|
60 |
175
57e324fa4350
implement getting a list of feeds that have unread entries
dirk
parents:
174
diff
changeset
|
61 def feedsWithUnreadEntries(): |
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
dirk
parents:
180
diff
changeset
|
62 return design_document + "/feeds_with_unread_entries" |