Skip to content

Commit

Permalink
fix new task's being created with "No Context"
Browse files Browse the repository at this point in the history
The new task handler in braindump.py would blindly pass a ContextNone in the
contexts array to the Task constructor.  This would get saved in the xmlstore,
and when subsequently loaded, the reference would never get resolved as a new
ContextNone is created with each application start (and is not saved in the
xmlstore).  We represent ContextNone in the Task objects with an empty
contexts array.  I'd like to scrap all the gtd.*None classes eventually.

Signed-off-by: Darren Hart <darren@dvhart.com>
  • Loading branch information
dvhart committed Apr 15, 2009
1 parent b4aa915 commit 76e9fdd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions braindump.py
Expand Up @@ -416,8 +416,11 @@ def on_work_with_projects_toggled(self, widget):
def on_new_task(self, title):
'''Create a new task from the new task defaults, initiated from the gtd_list.'''
project = self.default_project.get_active()
context = self.default_context.get_active()
task = gtd.Task.create(None, title, project, [context])
contexts = [self.default_context.get_active()]
# Don't store ContextNone in the task (we use an empty array to represent that)
if isinstance(contexts[0], gtd.ContextNone):
contexts = None
task = gtd.Task.create(None, title, project, contexts)
task.start_date = datetime.now()

def on_new_project(self, title):
Expand Down
3 changes: 3 additions & 0 deletions xmlstore.py
Expand Up @@ -136,6 +136,9 @@ def save_task(self, task):
task.project.title)
debug("saving contexts")
for c in task.contexts:
if isinstance(c, gtd.ContextNone):
error("ContextNone should not be stored in the task!")
continue
debug("referencing context: %s" % (c.title))
self._simple_element(x, "context_ref", {"id":str(c.id)}, c.title)
self._simple_element(x, "complete", {}, complete_str)
Expand Down

0 comments on commit 76e9fdd

Please sign in to comment.