How Sugar will interact with the DS for the May 17th demo in Argentina: >>> from olpc.datastore import DataStore >>> from olpc.datastore import backingstore >>> ds = DataStore() >>> ds.registerBackend(backingstore.FileBackingStore) >>> assert ds.mount("/tmp/test_ds") Create an entry without data: >>> uid = ds.create(dict(title="New entry"), '') >>> ds.complete_indexing() >>> ds.get_filename(uid) '' Update an entry without data: >>> ds.update(uid, dict(title="New entry still without content"), '') >>> ds.complete_indexing() >>> ds.get_filename(uid) '' Add some data to the same entry: >>> fp = open('/tmp/sugar_ds_test', 'w') >>> print >>fp, "some content" >>> fp.close() >>> ds.update(uid, dict(title="Same entry now with some content"), fp.name) >>> ds.complete_indexing() Retrieve that data: >>> fn = ds.get_filename(uid) >>> fp = open(fn, 'r') >>> fp.read() 'some content\n' >>> fp.close() Update again: >>> fp = open('/tmp/sugar_ds_test2', 'w') >>> print >>fp, "some other content" >>> fp.close() >>> ds.update(uid, dict(title="Same entry with some other content"), fp.name) >>> ds.complete_indexing() And retrieve again: >>> fn = ds.get_filename(uid) >>> fp = open(fn, 'r') >>> fp.read() 'some other content\n' >>> fp.close() Get all entries (only have one): >>> results, count = ds.find({}) >>> results[0]['title'] 'Same entry with some other content' Check content: >>> fn = ds.get_filename(uid) >>> fp = open(fn, 'r') >>> fp.read() 'some other content\n' >>> fp.close() Set content as pdf: >>> ds.update(uid, dict(title="Same entry with some content in pdf"), 'test.pdf') >>> ds.update(uid, dict(title="Same entry with some content in doc"), 'test.doc') >>> ds.update(uid, dict(title="Same entry with some content in odt"), 'test.odt') >>> ds.complete_indexing() >>> ds.stop() >>> del ds