Development Team/Almanac/sugar.datastore.datastore: Difference between revisions

Line 135: Line 135:


=== How do I access the metadata entries for a datastore object? ===
=== How do I access the metadata entries for a datastore object? ===
Every DSObject created by datastore.create() has a metadata property. This property refers to a [[#Class: DSMetadata | DSMetadata object]], which contains the metadata for your datastore object. The code below shows how to read metadata values by referring to the metadata property of a DSObject. metadata is a Python dictionary object.
Every DSObject created by datastore.create() has a metadata property. This property refers to a [[Low-level_Activity_API#Meta_Data]], which contains the metadata for your datastore object. The code below shows how to read metadata values by referring to the metadata property of a DSObject. metadata is a Python dictionary object.
<pre>
<pre>
from sugar.datastore import datastore
from sugar.datastore import datastore
Line 146: Line 146:
         print my_dsobject.metadata['description']
         print my_dsobject.metadata['description']


        #other standard objects in the metadata dictionary include 'tags', 'title', 'mimetypes', ...
</pre>
</pre>