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/Read_only_notebook.py
Dan Helfman 4e28620348 * Added a trash Notebook to model.Notebook.
* Made sure the trash is not exposed by the read-only notebook view.
 * Modified model.User.check_access() to consider read-write access to a
   notebook to be sufficient for access to that notebook's trash.
 * Modified controller.Users so new users are created with a notebook that
   has a trash.
 * Changed controller.Notebooks so deleted notes go to the trash (if any).
2007-08-03 21:12:17 +00:00

32 lines
964 B
Python

from Persistent import Persistent
class Read_only_notebook( Persistent ):
"""
A wrapper for Notebook that hides all of its destructive update functions.
"""
def __init__( self, id, notebook ):
Persistent.__init__( self, id )
self.__wrapped = notebook
def lookup_note( self, note_id ):
return self.__wrapped.lookup_note( note_id )
def lookup_note_by_title( self, title ):
return self.__wrapped.lookup_note_by_title( title )
def to_dict( self ):
d = self.__wrapped.to_dict()
del( d[ "trash" ] ) # don't expose the trash to read-only views of this notebook
d.update( dict(
object_id = self.object_id,
read_write = False,
) )
return d
name = property( lambda self: self.__wrapped.name )
trash = None # read-only access doesn't give you access to the Notebook's trash
notes = property( lambda self: self.__wrapped.notes )
startup_notes = property( lambda self: self.__wrapped.startup_notes )