Archived
1
0
This repository has been archived on 2023-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
luminotes/model/Persistent.py
Dan Helfman f05d3db661 * Added a "changes" tab with a list of revision timestamps for each note. Note yet clickable.
* Made controller.Notebooks.save_note() return the newly minted revision timestamp upon a successful save.
 * Whenever we get back a revision timestamp from save_note(), we store in in the client's list of revisions for that note.
 * Now raising Access_error in controller.Notebooks in various places where the notebook requested is unknown.
 * Tweaked pulldown CSS a bit. Now will sport a handy-dandy scrollbar if the pulldown gets too tall, at least in real browsers.
 * Fixed bug where clicking "show on startup" checkbox directly didn't visually toggle the checkbox.
2007-07-26 01:18:41 +00:00

43 lines
1.3 KiB
Python

from datetime import datetime
class Persistent( object ):
def __setstate__( self, state ):
key = "_Persistent__revisions_list"
if key not in state:
state[ key ] = [ state[ "_Persistent__revision" ] ]
self.__dict__.update( state )
def __init__( self, object_id, secondary_id = None ):
self.__object_id = object_id
self.__secondary_id = secondary_id
self.__revision = datetime.now()
self.__revisions_list = [ self.__revision ]
def update_revision( self ):
self.__revision = datetime.now()
self.__revisions_list.append( self.__revision )
def revision_id( self ):
return "%s %s" % ( self.__object_id, self.__revision )
@staticmethod
def make_revision_id( object_id, revision ):
return "%s %s" % ( object_id, revision )
def full_secondary_id( self ):
return "%s %s" % ( type( self ).__name__, self.secondary_id )
def to_dict( self ):
return dict(
object_id = self.__object_id,
revision = self.__revision,
revisions_list = self.__revisions_list,
)
object_id = property( lambda self: self.__object_id )
secondary_id = property( lambda self: self.__secondary_id )
revision = property( lambda self: self.__revision )
revisions_list = property( lambda self: self.__revisions_list )