[Sugar-devel] [PATCH Write] Optional data when it exports a file SL #2795

Manuel Kaufmann humitos at gmail.com
Thu May 24 10:37:01 EDT 2012


'keep' and 'share-scope' are optional metadata for the activity metadata, so we
should use them only if they are set before and if not we should use default
values for them. This patch fixes it.

For example, when the user downloads a file from Internet only 'keep' is set to
'0' but not 'share-scope'. A similar situation happens when a file is openen
with write from a pen-drive: neither 'keep' nor 'share-scope' are set for the
activity.

Signed-off-by: Manuel Kaufmann <humitos at gmail.com>
---
 widgets.py |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/widgets.py b/widgets.py
index 0df2b7e..f12544a 100644
--- a/widgets.py
+++ b/widgets.py
@@ -25,6 +25,8 @@ from sugar.graphics.toolbutton import ToolButton
 from sugar.graphics.menuitem import MenuItem
 from sugar.datastore import datastore
 
+from sugar.activity.activity import SCOPE_PRIVATE
+
 logger = logging.getLogger('write-activity')
 
 """
@@ -226,13 +228,14 @@ class ExportButtonFactory():
         if format['mime_type'] != 'application/pdf':
             fileObject.metadata['activity'] = act_meta['activity']
 
-        fileObject.metadata['keep'] = act_meta['keep']
+        fileObject.metadata['keep'] = act_meta.get('keep', '0')
 
         preview = activity.get_preview()
         if preview is not None:
             fileObject.metadata['preview'] = dbus.ByteArray(preview)
 
-        fileObject.metadata['share-scope'] = act_meta['share-scope']
+        fileObject.metadata['share-scope'] = act_meta.get('share-scope',
+                                                          SCOPE_PRIVATE)
 
         # write out the document contents in the requested format
         fileObject.file_path = os.path.join(activity.get_activity_root(),
-- 
1.7.10



More information about the Sugar-devel mailing list