From 99a6f57f2fbe89d04d41ccf31903144afe4249f5 Mon Sep 17 00:00:00 2001 From: Andi_G Date: Wed, 07 Sep 2011 02:17:10 +0000 Subject: further handling of remote annotations --- diff --git a/annobookmark.py b/annobookmark.py index d6fbb33..65448f0 100644 --- a/annobookmark.py +++ b/annobookmark.py @@ -86,8 +86,8 @@ class AnnoBookmark: self.mimetype = data[14] self.uuid = data[15] self.annotationurl = data[16] - if ( ( self.uuid == None ) or ( len( self.uuid ) == 0 ) ) and ( self.md5 != None ) and ( self.id != None ): - self.uuid = "urn:sugaruuid:" + self.creator + "-" + self.md5 + "-" + str(self.id) + if ( ( self.uuid == None ) or ( len( self.uuid ) == 0 ) ): + self.make_new_uuid() _logger.debug('annobookmark annotates is %s' % self.annotates) if ( self.annotationurl == None ): @@ -107,6 +107,11 @@ class AnnoBookmark: return r + def make_new_uuid(self): + if ( self.md5 != None ) and ( self.id != None ): + self.uuid = "urn:sugaruuid:" + self.creator + "-" + self.md5 + "-" + str(self.id) + + def belongstopage(self, page): return self.page == page @@ -162,6 +167,9 @@ class AnnoBookmark: def get_creator(self): return self.creator + def set_creator(self, creator): + self.creator = creator + def get_target(self): return self.get_annotates() diff --git a/readdb.py b/readdb.py index c19ef6d..e2e7687 100644 --- a/readdb.py +++ b/readdb.py @@ -371,11 +371,12 @@ class AnnotationManager: for a in self._annotations: if a.get_id() == annotation_id: - a.set_modified(time.time()) - a.set_note_title(annotitle) - a.set_note_body(annocontent) - self.update_annotation_db_record(a) - break + if ( a.get_note_title() != annotitle ) or ( a.get_note_body() != annocontent ): + a.set_modified(time.time()) + a.set_note_title(annotitle) + a.set_note_body(annocontent) + self.update_annotation_db_record(a) + break @@ -607,8 +608,15 @@ class AnnotationManager: def update_annotation_db_record(self, annotation): + #if a user changes a annotation, it becomes her own + if self._userid == '': + client = gconf.client_get_default() + user = client.get_string("/desktop/sugar/user/nick") + self._userid = self.get_userid_for_username( self.get_user_string( user ) ) + annotation.set_creator( self._userid ) + annotation.make_new_uuid() #(id INTEGER PRIMARY KEY, md5, page, title, content, bodyurl, texttitle, textcreator, created TIMESTAMP, modified TIMESTAMP, creator, annotates, color, local, mimetype, uuid, annotationurl) - t = (annotation.get_filehash(), annotation.get_page(), annotation.get_note_title(), annotation.get_note_body(), annotation.get_bodyurl(), annotation.get_texttitle(), annotation.get_textcreator(), annotation.get_created(), annotation.get_modified(), annotation.get_creator(), annotation.get_annotates(), annotation.get_color().to_string(), annotation.is_local(), annotation.get_mimetype(), annotation.get_uuid(), annotation.get_annotationurl(), annotation.get_id()) + t = (annotation.get_filehash(), annotation.get_page(), annotation.get_note_title(), annotation.get_note_body(), annotation.get_bodyurl(), annotation.get_texttitle(), annotation.get_textcreator(), annotation.get_created(), annotation.get_modified(), self._userid, annotation.get_annotates(), annotation.get_color().to_string(), annotation.is_local(), annotation.get_mimetype(), annotation.get_uuid(), annotation.get_annotationurl(), annotation.get_id()) self._conn.execute('update annotations set md5=?, page=?, title=?, content=?, bodyurl=?, texttitle=?, textcreator=?, created=?, modified=?, creator=?, annotates=?, color=?, local=?, mimetype=?, uuid=?, annotationurl=? where id=?', t) self._conn.commit() self.current_annotation = annotation -- cgit v0.9.1