diff options
author | Manuel Kaufmann <humitos@gmail.com> | 2012-05-24 14:31:59 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2012-06-01 19:31:58 (GMT) |
commit | ed689464d8e8d8114e4b9b1d15f4167f0469e3bd (patch) | |
tree | dba512a306716a44e7ecbad8a2bbb7ca9b834d69 /widgets.py | |
parent | daad87349c0bed3ce6dd4ba6dfc1f46afed533c9 (diff) |
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 <humitos@gmail.com>
Reviewed-By: Sascha Silbe <silbe@activitycentral.com>
Diffstat (limited to 'widgets.py')
-rw-r--r-- | widgets.py | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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(), |