From ed689464d8e8d8114e4b9b1d15f4167f0469e3bd Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Thu, 24 May 2012 14:31:59 +0000 Subject: Optional data when it exports a file SL #2795 '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 Reviewed-By: Sascha Silbe --- (limited to 'widgets.py') 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(), -- cgit v0.9.1