#15: Initial work for persistance size limiting.

This commit is contained in:
Bill Dengler 2015-05-09 23:04:06 -04:00
parent 4d4816a61b
commit f394701789
4 changed files with 21 additions and 8 deletions

View File

@ -12,7 +12,7 @@ reverse_timelines = boolean(default=False)
time_to_check_streams = integer(default=30)
announce_stream_status = boolean(default=True)
retweet_mode = string(default="ask")
persistant_session = boolean(default=True)
persist_size = integer(default=1764)
buffer_order = list(default=list('home','mentions','dm','sent_dm','sent_tweets','favorites','followers','friends','blocks','muted','events'))
[sound]

View File

@ -6,6 +6,7 @@ import paths
import widgetUtils
import config
import languageHandler
import output
from wxUI.dialogs import configuration
from wxUI import commonMessageDialogs
from extra.autocompletionUsers import settings
@ -89,7 +90,7 @@ class accountSettingsController(globalSettingsController):
self.dialog.set_value("general", "retweet_mode", _(u"Retweet without comments"))
else:
self.dialog.set_value("general", "retweet_mode", _(u"Retweet with comments"))
self.dialog.set_value("general", "persistant_session", self.config["general"]["persistant_session"])
self.dialog.set_value("general", "persist_size", str(self.config["general"]["persist_size"]))
self.dialog.create_other_buffers()
buffer_values = self.get_buffers_list()
self.dialog.buffers.insert_buffers(buffer_values)
@ -129,9 +130,15 @@ class accountSettingsController(globalSettingsController):
self.config["general"]["relative_times"] = self.dialog.get_value("general", "relative_time")
self.config["general"]["max_api_calls"] = self.dialog.get_value("general", "apiCalls")
self.config["general"]["max_tweets_per_call"] = self.dialog.get_value("general", "itemsPerApiCall")
if self.config["general"]["persistant_session"] != self.dialog.get_value("general", "persistant_session"):
self.needs_restart = True
self.config["general"]["persistant_session"] = self.dialog.get_value("general", "persistant_session")
if self.config["general"]["persist_size"] != self.dialog.get_value("general", "persist_size"):
if self.dialog.get_value("general", "persist_size") == '':
self.config["general"]["persist_size"] =-1
else:
try:
self.config["general"]["persist_size"] = int(self.dialog.get_value("general", "persist_size"))
except ValueError:
output.speak("Invalid cache size, setting to default.",True)
self.config["general"]["persist_size"] =1764
if self.config["general"]["reverse_timelines"] != self.dialog.get_value("general", "reverse_timelines"):
self.needs_restart = True

View File

@ -113,7 +113,7 @@ class Session(object):
log.debug("Creating config file %s" % (file_,))
self.settings = config_utils.load_config(paths.config_path(file_), paths.app_path("Conf.defaults"))
self.init_sound()
if self.settings["general"]["persistant_session"] == True:
if self.settings["general"]["persist_size"] != 0:
self.deshelve()
# except:
# log.exception("The session configuration has failed.")
@ -378,7 +378,10 @@ class Session(object):
if type(key) != str and type(key) != unicode:
output.speak("Uh oh, while shelving the database, a key of type " + str(type(key)) + " has been found. It will be converted to type str, but this will cause all sorts of problems on deshelve. Please bring this to the attention of the " + application.name + " developers immediately. More information about the error will be written to the error log.",True)
log.error("Uh oh, " + str(key) + " is of type " + str(type(key)) + "!")
shelf[str(key)]=value
if type(value) == List and self.settings["general"]["persist_size"] != -1 and len(type) > self.settings["general"]["persist_size"]:
shelf[str(key)]=value[self.settings["general"]["persist_size"]:]
else:
shelf[str(key)]=value
shelf.close()
except:
output.speak("An exception occurred while shelving the " + application.name + " database. It will be deleted and rebuilt automatically. If this error persists, send the error log to the " + application.name + " developers.",True)

View File

@ -92,7 +92,10 @@ class generalAccount(wx.Panel, baseDialog.BaseWXDialog):
rMode.Add(lbl, 0, wx.ALL, 5)
rMode.Add(self.retweet_mode, 0, wx.ALL, 5)
sizer.Add(rMode, 0, wx.ALL, 5)
self.persistant_session = wx.CheckBox(self, -1, _(u"Cache session in database (experimental)"))
PersistSizeLabel = wx.StaticText(self, -1, _(u"Number of items per buffer to cache in database (0 to disable caching, blank for unlimited)"))
self.persist_size = wx.TextCtrl(self, -1)
sizer.Add(PersistSizeLabel, 0, wx.ALL, 5)
sizer.Add(self.persist_size, 0, wx.ALL, 5)
self.SetSizer(sizer)
class other_buffers(wx.Panel):