From 7a20579c035a8ae2f298bd81552f35f1d1f53ed4 Mon Sep 17 00:00:00 2001
Message-Id: <7a20579c035a8ae2f298bd81552f35f1d1f53ed4.1337870145.git.humitos@gmail.com>
From: Manuel Kaufmann <humitos@gmail.com>
Date: Thu, 24 May 2012 11:31:59 -0300
Subject: [PATCH Write] 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>
---
widgets.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/widgets.py b/widgets.py
index 0df2b7e..f12544a 100644
a
|
b
|
from sugar.graphics.toolbutton import ToolButton |
25 | 25 | from sugar.graphics.menuitem import MenuItem |
26 | 26 | from sugar.datastore import datastore |
27 | 27 | |
| 28 | from sugar.activity.activity import SCOPE_PRIVATE |
| 29 | |
28 | 30 | logger = logging.getLogger('write-activity') |
29 | 31 | |
30 | 32 | """ |
… |
… |
class ExportButtonFactory(): |
226 | 228 | if format['mime_type'] != 'application/pdf': |
227 | 229 | fileObject.metadata['activity'] = act_meta['activity'] |
228 | 230 | |
229 | | fileObject.metadata['keep'] = act_meta['keep'] |
| 231 | fileObject.metadata['keep'] = act_meta.get('keep', '0') |
230 | 232 | |
231 | 233 | preview = activity.get_preview() |
232 | 234 | if preview is not None: |
233 | 235 | fileObject.metadata['preview'] = dbus.ByteArray(preview) |
234 | 236 | |
235 | | fileObject.metadata['share-scope'] = act_meta['share-scope'] |
| 237 | fileObject.metadata['share-scope'] = act_meta.get('share-scope', |
| 238 | SCOPE_PRIVATE) |
236 | 239 | |
237 | 240 | # write out the document contents in the requested format |
238 | 241 | fileObject.file_path = os.path.join(activity.get_activity_root(), |