From 7119032909c15fe2111c1197da4a4cce69b33a1c Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 17 Apr 2009 21:04:45 -0500 Subject: [PATCH] Adding save/load to backend interface --- src/file_backend.py | 18 +++++++++++++++++- src/null_backend.py | 6 ++++++ src/rtm_backend.py | 6 ++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/file_backend.py b/src/file_backend.py index 2493e8d..93cee59 100644 --- a/src/file_backend.py +++ b/src/file_backend.py @@ -1,4 +1,5 @@ import uuid +import pickle import datetime import toolbox @@ -6,11 +7,26 @@ import toolbox class FileManager(object): - def __init__(self): + def __init__(self, filename): + self._filename = filename self._projects = {} self._items = {} self._locations = {} + def save(self): + state = { + "projects": self._projects, + "items": self._items, + "locations": self._locations, + } + pickle.dump(state, self._filename) + + def load(self): + state = pickle.load(self._filename) + self._projects = state["projects"] + self._items = state["items"] + self._locations = state["locations"] + def add_project(self, name): projId = uuid.uuid4().hex projDetails = { diff --git a/src/null_backend.py b/src/null_backend.py index 5997d13..d70d55e 100644 --- a/src/null_backend.py +++ b/src/null_backend.py @@ -3,6 +3,12 @@ class NullManager(object): def __init__(self, username, password, token=None): pass + def save(self): + pass + + def load(self): + pass + def add_project(self, name): raise NotImplementedError("Not logged in to any ToDo system") diff --git a/src/rtm_backend.py b/src/rtm_backend.py index 9d7cb5f..d724d13 100644 --- a/src/rtm_backend.py +++ b/src/rtm_backend.py @@ -39,6 +39,12 @@ class RtMilkManager(object): self._timeline = resp.timeline self._lists = [] + def save(self): + pass + + def load(self): + pass + def add_project(self, name): rsp = self._rtm.lists.add( timeline=self._timeline, -- 1.7.9.5