X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/blobdiff_plain/11b50d11a86a461740d217dbebb896d119c955bc..ca70e43e55be6a99cf5d2b94301a558c8a9ca73c:/docs/index.rst diff --git a/docs/index.rst b/docs/index.rst index 90cd94b..6b9a6c3 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -239,6 +239,27 @@ same Python object:: >>> task3 == task1 True +Accessing original values +------------------------- + +To access the saved state of the Task, use dict-like access using the +``original`` attribute: + + >>> t = Task(tw, description="tidy up") + >>> t.save() + >>> t['description'] = "tidy up the kitchen and bathroom" + >>> t['description'] + "tidy up the kitchen and bathroom" + >>> t.original['description'] + "tidy up" + +When you save the task, original values are refreshed to reflect the +saved state of the task: + + >>> t.save() + >>> t.original['description'] + "tidy up the kitchen and bathroom" + Dealing with dates and time --------------------------- @@ -312,7 +333,7 @@ are set in the same timezone: >>> t['due'] datetime.datetime(2015, 2, 1, 19, 44, 4, 770001, tzinfo=) >>> now.astimezone(pytz.utc) - datetime.datetime(2015, 2, 1, 18, 44, 4, 770001, tzinfo=) + datetime.datetime(2015, 2, 1, 18, 44, 4, 770001, tzinfo=) >>> t['due'] == now.astimezone(pytz.utc) True @@ -424,6 +445,15 @@ Consenquently, you can create just one hook file for both ``on-add`` and This removes the need for maintaining two copies of the same code base and/or boilerplate code. +In ``on-modify`` events, tasklib loads both the original version and the modified +version of the task to the returned ``Task`` object. To access the original data +(in read-only manner), use ``original`` dict-like attribute: + + >>> t = Task.from_input() + >>> t['description'] + "Modified description" + >>> t.original['description'] + "Original description" Working with UDAs -----------------