Ticket #2795: 0001-Optional-data-when-it-exports-a-file-SL-2795.patch

File 0001-Optional-data-when-it-exports-a-file-SL-2795.patch, 2.0 KB (added by humitos, 12 years ago)
  • widgets.py

    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 
    2525from sugar.graphics.menuitem import MenuItem
    2626from sugar.datastore import datastore
    2727
     28from sugar.activity.activity import SCOPE_PRIVATE
     29
    2830logger = logging.getLogger('write-activity')
    2931
    3032"""
    class ExportButtonFactory(): 
    226228        if format['mime_type'] != 'application/pdf':
    227229            fileObject.metadata['activity'] = act_meta['activity']
    228230
    229         fileObject.metadata['keep'] = act_meta['keep']
     231        fileObject.metadata['keep'] = act_meta.get('keep', '0')
    230232
    231233        preview = activity.get_preview()
    232234        if preview is not None:
    233235            fileObject.metadata['preview'] = dbus.ByteArray(preview)
    234236
    235         fileObject.metadata['share-scope'] = act_meta['share-scope']
     237        fileObject.metadata['share-scope'] = act_meta.get('share-scope',
     238                                                          SCOPE_PRIVATE)
    236239
    237240        # write out the document contents in the requested format
    238241        fileObject.file_path = os.path.join(activity.get_activity_root(),