diff options
author | Andi_G <andigros72@googlemail.com> | 2011-09-04 21:04:45 (GMT) |
---|---|---|
committer | Andi_G <andigros72@googlemail.com> | 2011-09-04 21:04:45 (GMT) |
commit | 820a2c77b8e7430a332301fff8c84f8362f6323b (patch) | |
tree | 122b4bf705ba0dbe31a98322de4463855fabf951 | |
parent | d0209771a26a2cb6c7fd5e0ad06eb7817778123a (diff) |
updated annotation handling
-rw-r--r-- | readdb.py | 27 |
1 files changed, 13 insertions, 14 deletions
@@ -383,17 +383,17 @@ class AnnotationManager: def del_annotation(self, annotation_id): client = gconf.client_get_default() user = client.get_string("/desktop/sugar/user/nick") - #get the clientuuid to schedule its deletion on the annotation server - rows = self._conn.execute('select uuid from annotations where md5=? and id=?', [self._filehash, annotation_id]) - row = rows.fetchone() - self._to_delete.append(row[0]) - _logger.debug(str('schedule annotation %s for deletion' % str(row))) if self._userid == '': self._userid = self.get_userid_for_username( self.get_user_string( user ) ) - # We delete only the locally made annotation - t = (self._filehash, annotation_id, self._userid) + #get the clientuuid to schedule its deletion on the annotation server + rows = self._conn.execute('select uuid, creator from annotations where md5=? and id=?', [self._filehash, annotation_id]) + row = rows.fetchone() + if row[1] == self._userid: + self._to_delete.append(row[0]) + _logger.debug(str('schedule annotation %s for deletion' % str(row))) + t = (self._filehash, annotation_id) _logger.debug(str('t for deletion is %s' % str(t))) - self._conn.execute('delete from annotations where md5=? and id=? and creator=?', t) + self._conn.execute('delete from annotations where md5=? and id=?', t) check = self._conn.commit() _logger.debug('deletion check %s ', str(check)) self._resync_annotation_cache() @@ -719,12 +719,11 @@ class AnnotationManager: values = {'w3c_hasTarget' : self._filehash, 'creator' : self._creator } _logger.debug('sync annotations -- annotates is: %s ' % self._annotates) try: - data = urllib.urlencode(values) - req = urllib2.Request(url, data) - response = urllib2.urlopen(req) - annojson = response.read() + data = urllib.urlencode(values) + req = urllib2.Request(url, data) + response = urllib2.urlopen(req) + annojson = response.read() _logger.debug('downloaded annotations -- annojson is: %s ' % annojson) - except Exception, detail: _logger.debug("readdb: failure at initial sync request f. annotations; detail: %s ", detail) if ( not annojson == None ) and ( len( annojson ) > 0 ): @@ -758,7 +757,7 @@ class AnnotationManager: if (len(self._annotations) > 0): #send annotations if necessary for annotation in self._annotations: - if not annotation.get_uuid() in remote_uuids: + if ( not annotation.get_uuid() in remote_uuids ) and ( len( annotation.get_creator() ) > 0 ) and ( annotation.get_creator() == self._userid ): self.send_annotation_to_server(annotation) |