From 15d47587662014900773e72164012a2a564a87a1 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Tue, 17 Jul 2007 17:29:47 +0000 Subject: [PATCH] Fixed __setstate__() methods to update revision. --- model/Entry.py | 4 +++- model/Note.py | 4 +++- model/Notebook.py | 12 +++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/model/Entry.py b/model/Entry.py index 1689937..e099e9c 100644 --- a/model/Entry.py +++ b/model/Entry.py @@ -7,7 +7,9 @@ from controller.Html_nuker import Html_nuker class Entry( Persistent ): def __setstate__(self, state): self.__dict__.update(state) - self.__class__ = Note + if self.__class__ != Note: + self.update_revision() + self.__class__ = Note """ An single textual wiki entry. diff --git a/model/Note.py b/model/Note.py index d447836..6098356 100644 --- a/model/Note.py +++ b/model/Note.py @@ -8,10 +8,12 @@ class Note( Persistent ): if "_Entry__title" in state: state[ "_Note__title" ] = state[ "_Entry__title" ] del( state[ "_Entry__title" ] ) + self.update_revision() if "_Entry__contents" in state: state[ "_Note__contents" ] = state[ "_Entry__contents" ] del( state[ "_Entry__contents" ] ) - self.__dict__ = state + self.update_revision() + self.__dict__.update( state ) """ An single textual wiki note. diff --git a/model/Notebook.py b/model/Notebook.py index b20256a..9e99bda 100644 --- a/model/Notebook.py +++ b/model/Notebook.py @@ -8,9 +8,11 @@ class Notebook( Persistent ): if "_Notebook__entries" in state: state[ "_Notebook__notes" ] = state[ "_Notebook__entries" ] del( state[ "_Notebook__entries" ] ) + self.update_revision() if "_Notebook__startup_entries" in state: state[ "_Notebook__startup_notes" ] = state[ "_Notebook__startup_entries" ] del( state[ "_Notebook__startup_entries" ] ) + self.update_revision() self.__dict__.update(state) """ @@ -38,12 +40,12 @@ class Notebook( Persistent ): Persistent.__init__( self, id ) self.__name = name self.__notes = {} # map of note id to note - self.__titles = {} # map of note title to note + self.__titles = {} # map of note title to note self.__startup_notes = [] # list of notes shown on startup def add_note( self, note ): """ - Add an note to this notebook. + Add a note to this notebook. @type note: Note @param note: note to add @@ -54,7 +56,7 @@ class Notebook( Persistent ): def remove_note( self, note ): """ - Remove an note from this notebook. + Remove a note from this notebook. @type note: Note @param note: note to remove @@ -118,7 +120,7 @@ class Notebook( Persistent ): def add_startup_note( self, note ): """ - Add the given note to be shown on startup. It must already be an note in this notebook. + Add the given note to be shown on startup. It must already be a note in this notebook. @type note: unicode @param note: note to be added for startup @@ -128,7 +130,7 @@ class Notebook( Persistent ): """ if self.__notes.get( note.object_id ) is None: raise Notebook.UnknownNoteError( note.object_id ) - + if not note in self.__startup_notes: self.update_revision() self.__startup_notes.append( note )