Changes

Jump to navigation Jump to search
Line 133: Line 133:     
= Class: DSObject =
 
= Class: DSObject =
 +
 +
=== How do I create 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.
 +
<pre>
 +
from sugar.datastore import datastore
 +
...
 +
        #my_dsobject is of type datastore.DSObject
 +
        #object_id is a datastore object (returned from the datastore Chooser
 +
        my_dsobject = datastore.get(object_id)
 +
       
 +
        #Access the 'description' property
 +
        print my_dsobject.metadata['description']
 +
 +
        #other standard objects in the metadata dictionary include 'tags',
 +
</pre>
    
=== How do I create new metadata entries or reassign metadata for a datastore object that has been created? ===
 
=== How do I create new metadata entries or reassign metadata for a datastore object that has been created? ===

Navigation menu