Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndi_G <andigros72@googlemail.com>2011-09-07 02:17:10 (GMT)
committer Andi_G <andigros72@googlemail.com>2011-09-07 02:17:10 (GMT)
commit99a6f57f2fbe89d04d41ccf31903144afe4249f5 (patch)
tree6a639eeeaf5bc085730456486f927253df899dd3
parent24e894da03476cd342d577af03509141fd981597 (diff)
further handling of remote annotations
-rw-r--r--annobookmark.py12
-rw-r--r--readdb.py20
2 files changed, 24 insertions, 8 deletions
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