[Bugs] #1765 UNSP: Changes to a Journal entries metadata are wiped if activity is still open (0.84)

Sugar Labs Bugs bugtracker-noreply at sugarlabs.org
Wed Mar 24 14:19:44 EDT 2010


#1765: Changes to a Journal entries metadata are wiped if activity is still open
(0.84)
------------------------------------------+---------------------------------
    Reporter:  erikos                     |          Owner:  erikos     
        Type:  defect                     |         Status:  assigned   
    Priority:  Unspecified by Maintainer  |      Milestone:  0.88       
   Component:  sugar-toolkit              |        Version:  0.84.x     
    Severity:  Critical                   |     Resolution:             
    Keywords:  r?, olpc-0.84              |   Distribution:  Unspecified
Status_field:  New                        |  
------------------------------------------+---------------------------------
Changes (by erikos):

  * keywords:  r? => r?, olpc-0.84
  * milestone:  0.84 => 0.88


Comment:

 Sayamindu, thanks for identifying this issue!

 I found out the following: When we copy (keep as) an entry we set the
 object_id to None (activity.activity.copy). We do this that on next save
 we create a new entry. Is a bit funky imho. Anyhow, in the old code we did
 not disconnect the handler in this case, and therefore tried to get the
 properties of a none object. The following code does take care of this:

 {{{
  diff --git a/src/sugar/datastore/datastore.py
 b/src/sugar/datastore/datastore.py
 index 26655a6..e264889 100644
 --- a/src/sugar/datastore/datastore.py
 +++ b/src/sugar/datastore/datastore.py
 @@ -139,6 +139,7 @@ class DSObject(object):
      """A representation of a DS entry."""

      def __init__(self, object_id, metadata=None, file_path=None):
 +        self._update_signal_match = None
          self.set_object_id(object_id)
          self._metadata = metadata
          self._file_path = file_path
 @@ -149,16 +150,18 @@ class DSObject(object):
          return self._object_id

      def set_object_id(self, object_id):
 +        if self._update_signal_match is not None:
 +            self._update_signal_match.remove()
          if object_id is not None:
 -            _get_data_store().connect_to_signal('Updated',
 -                                                self.__object_updated_cb,
 -                                                arg0=object_id)
 +            self._update_signal_match =
 _get_data_store().connect_to_signal( \
 +                    'Updated', self.__object_updated_cb, arg0=object_id)
 +
          self._object_id = object_id

      object_id = property(get_object_id, set_object_id)

      def __object_updated_cb(self, object_id):
 -        properties = _get_data_store().get_properties(self.object_id,
 +        properties = _get_data_store().get_properties(self._object_id,
                                                        byte_arrays=True)
          self._metadata.update(properties)

 }}}

 This fix should go into 0.88, too.

-- 
Ticket URL: <https://bugs.sugarlabs.org/ticket/1765#comment:10>
Sugar Labs <http://sugarlabs.org/>
Sugar Labs bug tracking system


More information about the Bugs mailing list