[Dextrose] [sugar mainline PATCH] sl#3605: Do not rely on 'mountpoint' property being present in the metadata per entry. Instead use the global API.

Ajay Garg ajay at activitycentral.com
Tue Jun 19 12:25:03 EDT 2012


Hi all.

In this patch, the 'mountpoint' property for a particular entry, is being
fetched via a semi-global context (in the sense that the 'mountpoint' is
updated whenever the user-clicks on the corresponding icon
(journal/documents/usb-drives) in the left-bottom-paneltray).

The other option, is to indeed investigate, and find out the reason for
'mountpoint' property not being linked on a per-entry basis. (Right now,
the 'mountpoint' property is present in some cases, but not in others).
However, I am a little sceptical, because of the following reasons ::


a)
The local VS global context as described above.


b)
There are other cases, wherein the metadata properties are not same in
number for every case.
In the ideal case, every entry (journal/documents/usb-drives) should have
the same number of metadata properties (since the metadata is for a
specific entry, wherein the metadata-properties-values may change, but not
metadata-properties-keys).


In fact, would removing the 'mountpoint' property (on a per-entry basis,
that is) altogether be a good idea?


Any how, I am not sure which is the right approach. Please let me know.


Thanks and Regards,
Ajay



On Tue, Jun 5, 2012 at 6:30 PM, <ajay at activitycentral.com> wrote:

> From: Ajay Garg <ajay at activitycentral.com>
>
> Following are the steps to reproduce the issue ::
>
> a)
> Ensure that the "Journal" and "Documents" are empty.
>
> b)
> Copy a file (I tried with a mp3) to a USB drive, from a non-XO machine.
>
> c)
> Insert the USB drive in the XO.
>
> d)
> Copy the file (of step b) ) to "Documents" folder.
>
> e)
> View Details of the copied entry (in "Documents").
>
> f)
> There should be the exception in the logs. Moreover, the "Description"
> field should be empty in the "Details View" (this field ought to be
> "/media/<name of USB drive>").
>
>
>
>  src/jarabe/journal/journalactivity.py |   12 ++++++++++++
>  src/jarabe/journal/model.py           |    8 +++++++-
>  2 files changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/src/jarabe/journal/journalactivity.py
> b/src/jarabe/journal/journalactivity.py
> index bb1c7f6..485e7b4 100644
> --- a/src/jarabe/journal/journalactivity.py
> +++ b/src/jarabe/journal/journalactivity.py
> @@ -53,6 +53,7 @@ _SPACE_TRESHOLD = 52428800
>  _BUNDLE_ID = 'org.laptop.JournalActivity'
>
>  _journal = None
> +_mount_point = None
>
>
>  class JournalActivityDBusService(dbus.service.Object):
> @@ -122,6 +123,8 @@ class JournalActivity(JournalWindow):
>         self._detail_toolbox = None
>         self._volumes_toolbar = None
>
> +        set_mount_point('/')
> +
>         self._setup_main_view()
>         self._setup_secondary_view()
>
> @@ -184,6 +187,7 @@ class JournalActivity(JournalWindow):
>         search_toolbar = self._main_toolbox.search_toolbar
>         search_toolbar.connect('query-changed', self._query_changed_cb)
>         search_toolbar.set_mount_point('/')
> +        set_mount_point('/')
>
>     def _setup_secondary_view(self):
>         self._secondary_view = gtk.VBox()
> @@ -253,6 +257,7 @@ class JournalActivity(JournalWindow):
>     def __volume_changed_cb(self, volume_toolbar, mount_point):
>         logging.debug('Selected volume: %r.', mount_point)
>         self._main_toolbox.search_toolbar.set_mount_point(mount_point)
> +        set_mount_point(mount_point)
>         self._main_toolbox.set_current_toolbar(0)
>
>     def __model_created_cb(self, sender, **kwargs):
> @@ -373,3 +378,10 @@ def get_journal():
>
>  def start():
>     get_journal()
> +
> +def set_mount_point(mount_point):
> +    global _mount_point
> +    _mount_point = mount_point
> +
> +def get_mount_point():
> +    return _mount_point
> diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py
> index 5285a7c..98b8e52 100644
> --- a/src/jarabe/journal/model.py
> +++ b/src/jarabe/journal/model.py
> @@ -793,7 +793,13 @@ def is_editable(metadata):
>      if metadata.get('mountpoint', '/') == '/':
>         return True
>     else:
> -        return os.access(metadata['mountpoint'], os.W_OK)
> +        # sl#3605: Instead of relying on mountpoint property being
> +        #          present in the metadata, use journalactivity api.
> +        #          This would work seamlessly, as "Details View' is
> +        #          called, upon an entry in the context of a singular
> +        #          mount-point.
> +        from jarabe.journal.journalactivity import get_mount_point
> +        return os.access(get_mount_point(), os.W_OK)
>
>
>  def get_documents_path():
> --
> 1.7.10.1
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/dextrose/attachments/20120619/85442d9c/attachment.html>


More information about the Dextrose mailing list