#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

@@ -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)