On Sat, 16 Jun 2007, Vera wrote:

I am Vera, Google Summer of Code student working on  progress reports
functionality for Chandler. Further info about the project plans in their
current state, please refer to
http://chandlerproject.org/Journal/ToStartWithProposal

Jeffrey recommended me to ask you about history information for items in the
repository. Specifically, I would like to know how  to access:

  Hi Vera,

The chandler repository is versioned. This means that until you compact it to delete old versions of items, everything you did is present. By default, the latest version of items are retrieved for you but there are many ways to get at the older stuff too. Morgen's history feature is an example of how these APIs can be used. The easiest way to access a Chandler repository's history and items *manually* is via the python interpreter you can use with 'headless' chandler. To do this:
  - create a chandler repository (or use an existing one)
  - instead of starting Chandler, start headless (this assumes you have a
    trunk or developer tree where you can start chandler from the command
    line) as follows:
    ./release/RunPython tools/headless.py
    You then see a python prompt:
    >>>
    at that prompt, type 'view'
    >>> view
    <DBRepositoryView: MainThread (2)>
    This means that the current (newest) version is version 2
    At this point, you can enter any number of calls into the repository that
    depend on what you'd like to do.
    To start exploring (this is best done on a repository that has had some
    usage):
    >>> view.repository.printVersions()
    you should get a tabular printout of
     version, commit date, view size, commit size, view name
    where view size is the number of items loaded at the time of commit
    and commit size the number of items committed
    >>> view.repository.printItemVersions(item)
    every item has a UUID (universally unique id) that can be used to address
    it. For instance, if you want to see the history of versions of the
    chandler sidebar
    >>> sb = schema.ns('osaf.app', view).sidebarCollection
    >>> view.repository.printItemVersions(sb)
    Or, to see the history of item changes (the function Morgen is using as
    well)
    >>> view.printItemChanges(sb)
    All these functions are defined in repository/persistence/Repository.py
    and RepositoryView.py (for their view-specific counterparts).

1) deleted items

When you delete an item, that item is deleted from the current version.
That deletion is final - from that version on - once you've committed that version. You can of course go back in versions and retrieve this deleted item from versions prior to the deletion. For example, delete the Chandler welcome note:

ac = schema.ns('osaf.pim', view).allCollection
<SmartCollection: allCollection 44634e5c-1b64-11dc-a615-0017f2c66a51>
(this is the All Collection, also known as the Dashboard in the Chandler UI)
list(ac)
    [<Note: WelcomeEvent 4475afb6-1b64-11dc-a615-0017f2c66a51>, <Note:
     4481fd8e-1b64-11dc-a615-0017f2c66a51>, <Note:
     44829f64-1b64-11dc-a615-0017f2c66a51>, <Note:
     44834d1a-1b64-11dc-a615-0017f2c66a51>, <Note:
     44840c64-1b64-11dc-a615-0017f2c66a51>]
[i.displayName for i in ac]
    [u'Welcome to Chandler 0.7.dev-r14709', u'Try sharing a Home task list',
     u'Play around with the Calendar', u'Download Chandler', u'Set up your
     accounts']
You see that the welcome note is the first item in the All Collection.
wn = list(ac)[0]
wn
<Note: WelcomeEvent 4475afb6-1b64-11dc-a615-0017f2c66a51>
wn.delete(True)
wn
<Note (deferred): WelcomeEvent 4475afb6-1b64-11dc-a615-0017f2c66a51>
view.commit()
<DBRepositoryView: MainThread (2)> committed 13 items (9 kbytes) in 0:00:00.897865, 14 items/s (10 kbytes/s)
wn
<Item (deleted): WelcomeEvent 4475afb6-1b64-11dc-a615-0017f2c66a51>
Now, the welcome note is truly deleted.
If you quit headless now and restart (you don't have to quit and restart to see this, it's just an example)
view
<DBRepositoryView: MainThread (2)>
view.findUUID('4475afb6-1b64-11dc-a615-0017f2c66a51')
you get nothing back, but if you go back one version, you get the welcome note back:
view.itsVersion -= 1
view.findUUID('4475afb6-1b64-11dc-a615-0017f2c66a51')
<Note: WelcomeEvent 4475afb6-1b64-11dc-a615-0017f2c66a51>
The UUID I used here came from the previous headless session and will be different for you, of course.

2) the set of all the modifications that happen to an item

Two APIs:
  - view.printCurrentChanges(item) will display the current, uncommitted,
    modifications made to this item (with the exception, currently, of removed
    values) in this view. This API takes an optional 'True/False' argument to
    get more details or not (False by default).
  - view.repository.printItemChanges(item)
    view.printItemChanges(item)
    will display the history of changes to an item either in the entire
    repository or those made by this view.

3) at what triage status an item was created

Find the version the item was born at (created at) using view.repository.printItemVersions() and check the relevant attribute at that version. Here, it may get tricker because the attribute may be a more complicated concoction of names in case it's the attribute of a Stamp (an Annotation). For help, with these, first talk to the person responsible for the schema of 'triage', I suspect it's Bryan, but asking on IRC is the best way to go about this. They can then help you with wrapping your item with the correct Stamp/Annotation class to more easily retrieve this value. But, still, in headless, travelling up and down the version history of the repository by setting the view's itsVersion attribute is the entry point to most of this.

If you have more questions, do not hesitate to ask.

Andi..

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Open Source Applications Foundation "chandler-dev" mailing list
http://lists.osafoundation.org/mailman/listinfo/chandler-dev

Reply via email to