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 f23fcdde21 * Can now click on revision timestamps to open up the contents of previous note revisions with a small timestamp at the top.
* Revisions can be opened either in the current page or in a new window/tab.
 * Added ability for a read-write notebook to contain read-only notes. This supports showing read-only revisions.
 * Fixed updatedb.py to properly load the anonymous user.
 * Updated initdb.py and updatedb.py to deadl with new-style /notebooks/notebookid?note_id=noteid wiki links.
 * Made Persistent copy the revisions_list on each revision update so different revisions don't share lists.
 * Prevented Note from updating its revision twice upon construction. Now it's only updated once.
 * Work-around for nasty urlparse() caching bug related to unicode strings that cherrypy barfs on.
 * Added optional revision flag to various controller.Notebooks methods to allow opening of a notebook with a particular note revision displayed.
2007-07-31 22:53:57 +00:00

38 lines
1.2 KiB
Python

from datetime import datetime
class Persistent( object ):
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()
# make a new copy of the list to prevent sharing of this list between different revisions
self.__revisions_list = self.__revisions_list + [ 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 )