Mercurial > hg > Feedworm
annotate backend/couchdb/Preferences.py @ 156:2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Sat, 27 Aug 2011 10:17:07 +0200 |
parents | 8ec20377bcb0 |
children | e8bb107a74e1 |
rev | line source |
---|---|
133
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
1 |
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
2 class Preferences(object): |
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
3 def __init__(self, database): |
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
4 self.database = database |
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
5 self.viewResults = self.database.view("feedtest/preference_by_key") |
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
6 |
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
7 def _valueForKey(self, key): |
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
8 try: |
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
9 resultsForKey = self.viewResults[key] |
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
10 row = iter(resultsForKey).next() |
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
11 return row.value["value"] |
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
12 except StopIteration: |
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
13 return None |
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
14 |
156
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
15 def _booleanValueForKey(self, key): |
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
16 value = self._valueForKey(key) |
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
17 if value is None: |
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
18 return False |
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
19 else: |
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
20 return value |
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
21 |
133
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
22 def isProxyConfigured(self): |
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
23 return self.proxyHost() is not None |
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
24 |
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
25 def proxyHost(self): |
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
26 return self._valueForKey("proxyHost") |
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
27 |
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
28 def proxyPort(self): |
9e1e6b96d8b0
implement proxyHost/proxyPort in Preferences
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
29 return self._valueForKey("proxyPort") |
146
8ec20377bcb0
move getting the entries for a feed to the backend so that the couchdb backend can use a custom view for feed entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
133
diff
changeset
|
30 |
8ec20377bcb0
move getting the entries for a feed to the backend so that the couchdb backend can use a custom view for feed entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
133
diff
changeset
|
31 def showOnlyUnreadFeeds(self): |
156
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
32 return self._booleanValueForKey("showOnlyUnreadFeeds") |
146
8ec20377bcb0
move getting the entries for a feed to the backend so that the couchdb backend can use a custom view for feed entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
133
diff
changeset
|
33 |
8ec20377bcb0
move getting the entries for a feed to the backend so that the couchdb backend can use a custom view for feed entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
133
diff
changeset
|
34 def startMaximized(self): |
156
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
35 return self._booleanValueForKey("startMaximized") |
146
8ec20377bcb0
move getting the entries for a feed to the backend so that the couchdb backend can use a custom view for feed entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
133
diff
changeset
|
36 |
8ec20377bcb0
move getting the entries for a feed to the backend so that the couchdb backend can use a custom view for feed entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
133
diff
changeset
|
37 def hideReadFeedEntries(self): |
156
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
38 return self._booleanValueForKey("hideReadFeedEntries") |
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
39 |
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
40 def daysToKeepFeedEntries(self): |
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
41 days = self._valueForKey("daysToKeepFeedEntries") |
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
42 if days is not None: |
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
43 return days |
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
44 else: |
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
45 return 60 |
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
46 |
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
47 def rollback(self): |
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
48 # this method does nothing |
2d159eb2a91b
displaying the preferences dialog works, saving prefs doesn't yet
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
146
diff
changeset
|
49 pass |