Now that the databases are changed from Entry to Note, removing schema evolution stuff.
This commit is contained in:
parent
eb957d169b
commit
733e104872
|
@ -1,63 +0,0 @@
|
||||||
import re
|
|
||||||
from Persistent import Persistent
|
|
||||||
from controller.Html_nuker import Html_nuker
|
|
||||||
from model.Note import Note
|
|
||||||
|
|
||||||
|
|
||||||
class Entry( Persistent ):
|
|
||||||
def __setstate__(self, state):
|
|
||||||
if "_Entry__title" in state:
|
|
||||||
state[ "_Note__title" ] = state[ "_Entry__title" ]
|
|
||||||
del( state[ "_Entry__title" ] )
|
|
||||||
if "_Entry__contents" in state:
|
|
||||||
state[ "_Note__contents" ] = state[ "_Entry__contents" ].replace( "/entries/", "/notes/" )
|
|
||||||
del( state[ "_Entry__contents" ] )
|
|
||||||
self.__dict__.update( state )
|
|
||||||
self.__class__ = Note
|
|
||||||
|
|
||||||
"""
|
|
||||||
An single textual wiki entry.
|
|
||||||
"""
|
|
||||||
TITLE_PATTERN = re.compile( u"<h3>(.*)</h3>", flags = re.IGNORECASE )
|
|
||||||
|
|
||||||
def __init__( self, id, contents = None ):
|
|
||||||
"""
|
|
||||||
Create a new entry with the given id and contents.
|
|
||||||
|
|
||||||
@type id: unicode
|
|
||||||
@param id: id of the entry
|
|
||||||
@type contents: unicode or NoneType
|
|
||||||
@param contents: initial contents of the entry (optional)
|
|
||||||
@rtype: Entry
|
|
||||||
@return: newly constructed entry
|
|
||||||
"""
|
|
||||||
Persistent.__init__( self, id )
|
|
||||||
self.__title = None
|
|
||||||
self.__contents = None or ""
|
|
||||||
|
|
||||||
self.__set_contents( contents )
|
|
||||||
|
|
||||||
def __set_contents( self, contents ):
|
|
||||||
self.update_revision()
|
|
||||||
self.__contents = contents
|
|
||||||
|
|
||||||
# parse title out of the beginning of the contents
|
|
||||||
result = Entry.TITLE_PATTERN.search( contents )
|
|
||||||
|
|
||||||
if result:
|
|
||||||
self.__title = result.groups()[ 0 ]
|
|
||||||
self.__title = Html_nuker( allow_refs = True ).nuke( self.__title )
|
|
||||||
else:
|
|
||||||
self.__title = None
|
|
||||||
|
|
||||||
def to_dict( self ):
|
|
||||||
d = Persistent.to_dict( self )
|
|
||||||
d.update( dict(
|
|
||||||
contents = self.__contents,
|
|
||||||
title = self.__title,
|
|
||||||
) )
|
|
||||||
|
|
||||||
return d
|
|
||||||
|
|
||||||
contents = property( lambda self: self.__contents, __set_contents )
|
|
||||||
title = property( lambda self: self.__title )
|
|
|
@ -4,15 +4,6 @@ from Persistent import Persistent
|
||||||
|
|
||||||
|
|
||||||
class Notebook( Persistent ):
|
class Notebook( Persistent ):
|
||||||
def __setstate__(self, state):
|
|
||||||
if "_Notebook__entries" in state:
|
|
||||||
state[ "_Notebook__notes" ] = state[ "_Notebook__entries" ]
|
|
||||||
del( state[ "_Notebook__entries" ] )
|
|
||||||
if "_Notebook__startup_entries" in state:
|
|
||||||
state[ "_Notebook__startup_notes" ] = state[ "_Notebook__startup_entries" ]
|
|
||||||
del( state[ "_Notebook__startup_entries" ] )
|
|
||||||
self.__dict__.update(state)
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
A collection of wiki notes.
|
A collection of wiki notes.
|
||||||
"""
|
"""
|
||||||
|
|
Reference in New Issue