def setUp( self ): self.database = Database( Connection_wrapper( sqlite.connect( ":memory:", detect_types = sqlite.PARSE_DECLTYPES, check_same_thread = False ) ), cache = Stub_cache(), ) self.database.execute_script( file( "model/schema.sqlite" ).read(), commit = True ) self.username = u"mulder" self.password = u"trustno1" self.email_address = u"*****@*****.**" self.user = User.create( self.database.next_id( User ), self.username, self.password, self.email_address ) self.database.save( self.user, commit = False ) self.trash = Notebook.create( self.database.next_id( Notebook ), u"trash" ) self.database.save( self.trash, commit = False ) self.notebook = Notebook.create( self.database.next_id( Notebook ), u"notebook", self.trash.object_id, user_id = self.user.object_id ) self.database.save( self.notebook, commit = False ) note_id = self.database.next_id( Note ) self.note1 = Note.create( note_id, u"<h3>my title</h3>blah", notebook_id = self.notebook.object_id, startup = True, user_id = self.user.object_id ) self.database.save( self.note1, commit = False ) note_id = self.database.next_id( Note ) self.note2 = Note.create( note_id, u"<h3>other title</h3>whee", notebook_id = self.notebook.object_id, user_id = self.user.object_id ) self.database.save( self.note2, commit = False )
def __make_extra_threads(self): self.general_thread2 = Notebook.create(self.database.next_id(Notebook), u"How does this thing work?") self.database.save(self.general_thread2) self.database.execute( self.anonymous.sql_save_notebook( self.general_thread2.object_id, read_write=Notebook.READ_WRITE_FOR_OWN_NOTES), ) self.database.execute( self.anonymous.sql_save_notebook_tag( self.general_thread2.object_id, self.forum_tag.object_id, value=u"general"), ) self.general_thread3 = Notebook.create( self.database.next_id(Notebook), u"I have a problem with my pantalones.") self.database.save(self.general_thread3) self.database.execute( self.anonymous.sql_save_notebook( self.general_thread3.object_id, read_write=Notebook.READ_WRITE_FOR_OWN_NOTES), ) self.database.execute( self.anonymous.sql_save_notebook_tag( self.general_thread3.object_id, self.forum_tag.object_id, value=u"general"), )
def setUp( self ): Test_controller.setUp( self ) self.notebook = Notebook.create( self.database.next_id( Notebook ), u"my notebook", trash_id = u"foo" ) self.database.save( self.notebook ) self.anon_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes" ) self.database.save( self.anon_notebook ) self.anon_note = Note.create( self.database.next_id( Note ), u"<h3>my note</h3>", notebook_id = self.anon_notebook.object_id, ) self.database.save( self.anon_note ) self.login_note = Note.create( self.database.next_id( Note ), u"<h3>login</h3>", notebook_id = self.anon_notebook.object_id, ) self.database.save( self.login_note ) self.blog_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes blog" ) self.database.save( self.blog_notebook ) self.blog_note = Note.create( self.database.next_id( Note ), u"<h3>my blog entry</h3>", notebook_id = self.blog_notebook.object_id, ) self.database.save( self.blog_note ) self.guide_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes user guide" ) self.database.save( self.guide_notebook ) self.guide_note = Note.create( self.database.next_id( Note ), u"<h3>it's all self-explanatory</h3>", notebook_id = self.guide_notebook.object_id, ) self.database.save( self.guide_note ) self.privacy_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes privacy policy" ) self.database.save( self.privacy_notebook ) self.privacy_note = Note.create( self.database.next_id( Note ), u"<h3>yay privacy</h3>", notebook_id = self.privacy_notebook.object_id, ) self.database.save( self.privacy_note ) self.username = u"mulder" self.password = u"trustno1" self.email_address = u"*****@*****.**" self.user = None self.session_id = None self.user = User.create( self.database.next_id( User ), self.username, self.password, self.email_address ) self.database.save( self.user ) self.database.execute( self.user.sql_save_notebook( self.notebook.object_id ) ) self.anonymous = User.create( self.database.next_id( User ), u"anonymous" ) self.database.save( self.anonymous ) self.database.execute( self.anonymous.sql_save_notebook( self.anon_notebook.object_id, read_write = False, owner = False, rank = 0 ) ) self.database.execute( self.anonymous.sql_save_notebook( self.blog_notebook.object_id, read_write = False, owner = False, rank = 1 ) ) self.database.execute( self.anonymous.sql_save_notebook( self.guide_notebook.object_id, read_write = False, owner = False, rank = 2 ) ) self.database.execute( self.anonymous.sql_save_notebook( self.privacy_notebook.object_id, read_write = False, owner = False, rank = 3 ) )
def setUp( self ): self.object_id = "17" self.trash_id = "18" self.name = u"my notebook" self.trash_name = u"trash" self.user_id = u"me" self.delta = timedelta( seconds = 1 ) self.read_write = Notebook.READ_WRITE self.owner = False self.rank = 17.5 self.trash = Notebook.create( self.trash_id, self.trash_name, read_write = Notebook.READ_ONLY, deleted = False, user_id = self.user_id ) self.notebook = Notebook.create( self.object_id, self.name, trash_id = self.trash.object_id, deleted = False, user_id = self.user_id, read_write = self.read_write, owner = self.owner, rank = self.rank ) self.note = Note.create( "19", u"<h3>title</h3>blah" )
def create_thread( self, user_id ): """ Create a new forum thread with a blank post, and give the thread a default name. Then redirect to that new thread. @type user_id: unicode or NoneType @param user_id: id of current logged-in user (if any) @rtype dict @return { 'redirect': new_notebook_url } @raise Access_error: the current user doesn't have access to create a post @raise Validation_error: one of the arguments is invalid """ if user_id is None: raise Access_error() user = self.__database.load( User, user_id ) if user is None or not user.username or user.username == "anonymous": raise Access_error() anonymous = self.__database.select_one( User, User.sql_load_by_username( u"anonymous" ), use_cache = True ) if anonymous is None: raise Access_error() # for now, crappy hard-coding to prevent just anyone from creating a blog thread if self.__name == u"blog" and user.username != u"witten": raise Access_error() # create the new notebook thread thread_id = self.__database.next_id( Notebook, commit = False ) thread = Notebook.create( thread_id, self.DEFAULT_THREAD_NAME, user_id = user.object_id ) self.__database.save( thread, commit = False ) # associate the forum tag with the new notebook thread tag = self.__database.select_one( Tag, Tag.sql_load_by_name( u"forum", user_id = anonymous.object_id ) ) self.__database.execute( anonymous.sql_save_notebook_tag( thread_id, tag.object_id, value = self.__name ), commit = False, ) # give the anonymous user access to the new notebook thread self.__database.execute( anonymous.sql_save_notebook( thread_id, read_write = True, owner = False, own_notes_only = True ), commit = False, ) # create a blank post in which the user can start off the thread note_id = self.__database.next_id( Notebook, commit = False ) note = Note.create( note_id, u"<h3>", notebook_id = thread_id, startup = True, rank = 0, user_id = user_id ) self.__database.save( note, commit = False ) self.__database.commit() if self.__name == "blog": return dict( redirect = u"/blog/%s" % thread_id, ) return dict( redirect = u"/forums/%s/%s" % ( self.__name, thread_id ), )
def create_main_notebook(self): # create the main notebook main_notebook_id = self.database.next_id(Notebook) self.main_notebook = Notebook.create(main_notebook_id, u"Luminotes", rank=0) self.database.save(self.main_notebook, commit=False) # no need to create default notes for the desktop version if self.desktop is True: return # create an id for each note note_ids = {} for (filename, startup) in self.NOTE_FILES: note_ids[filename] = self.database.next_id(Note) rank = 0 for (filename, startup) in self.NOTE_FILES: full_filename = os.path.join(self.HTML_PATH, filename) contents = fix_note_contents( file(full_filename).read(), main_notebook_id, note_ids, self.settings) if startup: rank += 1 note = Note.create(note_ids[filename], contents, notebook_id=self.main_notebook.object_id, startup=startup, rank=startup and rank or None) self.database.save(note, commit=False)
def create_main_notebook( self ): # create the main notebook main_notebook_id = self.database.next_id( Notebook ) self.main_notebook = Notebook.create( main_notebook_id, u"Luminotes", rank = 0 ) self.database.save( self.main_notebook, commit = False ) # no need to create default notes for the desktop version if self.desktop is True: return # create an id for each note note_ids = {} for ( filename, startup ) in self.NOTE_FILES: note_ids[ filename ] = self.database.next_id( Note ) rank = 0 for ( filename, startup ) in self.NOTE_FILES: full_filename = os.path.join( self.HTML_PATH, filename ) contents = fix_note_contents( file( full_filename ).read(), main_notebook_id, note_ids, self.settings ) if startup: rank += 1 note = Note.create( note_ids[ filename ], contents, notebook_id = self.main_notebook.object_id, startup = startup, rank = startup and rank or None ) self.database.save( note, commit = False )
def __make_extra_threads( self ): self.general_thread2 = Notebook.create( self.database.next_id( Notebook ), u"How does this thing work?" ) self.database.save( self.general_thread2 ) self.database.execute( self.anonymous.sql_save_notebook( self.general_thread2.object_id, read_write = Notebook.READ_WRITE_FOR_OWN_NOTES ), ) self.database.execute( self.anonymous.sql_save_notebook_tag( self.general_thread2.object_id, self.forum_tag.object_id, value = u"general" ), ) self.general_thread3 = Notebook.create( self.database.next_id( Notebook ), u"I have a problem with my pantalones." ) self.database.save( self.general_thread3 ) self.database.execute( self.anonymous.sql_save_notebook( self.general_thread3.object_id, read_write = Notebook.READ_WRITE_FOR_OWN_NOTES ), ) self.database.execute( self.anonymous.sql_save_notebook_tag( self.general_thread3.object_id, self.forum_tag.object_id, value = u"general" ), )
def make_thread( self ): title = u"Welcome to the Luminotes %s forum!" % self.forum_name # create a notebook thread to go in the forum notebook_id = self.database.next_id( Notebook, commit = False ) thread_notebook = Notebook.create( notebook_id, title, ) self.database.save( thread_notebook, commit = False ) anonymous = self.database.select_one( User, User.sql_load_by_username( u"anonymous" ) ) # add a single welcome note to the new thread note_id = self.database.next_id( Note, commit = False ) note = Note.create( note_id, u""" <h3>%s</h3> You can discuss any Luminotes %s topics here. This is a public discussion forum, so please keep that in mind when posting. And have fun. """ % ( title, self.forum_name ), notebook_id, startup = True, rank = 0, user_id = anonymous.object_id, creation = datetime.now(), ) self.database.save( note, commit = False ) # load the forum tag, or create one if it doesn't exist tag = self.database.select_one( Tag, Tag.sql_load_by_name( u"forum", user_id = anonymous.object_id ) ) if not tag: tag_id = self.database.next_id( Tag, commit = False ) tag = Tag.create( tag_id, notebook_id = None, # this tag is not in the namespace of a single notebook user_id = anonymous.object_id, name = u"forum", description = u"discussion forum threads" ) self.database.save( tag, commit = False ) # associate the forum tag with the previously created notebook thread, and set that # association's value to forum_name self.database.execute( anonymous.sql_save_notebook_tag( notebook_id, tag.object_id, value = self.forum_name ), commit = False, ) # give the anonymous user access to the new notebook thread self.database.execute( anonymous.sql_save_notebook( notebook_id, read_write = True, owner = False, own_notes_only = True ), commit = False, )
def setUp(self): self.database = Database( Connection_wrapper( sqlite.connect(":memory:", detect_types=sqlite.PARSE_DECLTYPES, check_same_thread=False)), cache=Stub_cache(), ) self.database.execute_script(file("model/schema.sqlite").read(), commit=True) self.username = u"mulder" self.password = u"trustno1" self.email_address = u"*****@*****.**" self.user = User.create(self.database.next_id(User), self.username, self.password, self.email_address) self.database.save(self.user, commit=False) self.trash = Notebook.create(self.database.next_id(Notebook), u"trash") self.database.save(self.trash, commit=False) self.notebook = Notebook.create(self.database.next_id(Notebook), u"notebook", self.trash.object_id, user_id=self.user.object_id) self.database.save(self.notebook, commit=False) note_id = self.database.next_id(Note) self.note1 = Note.create(note_id, u"<h3>my title</h3>blah", notebook_id=self.notebook.object_id, startup=True, user_id=self.user.object_id) self.database.save(self.note1, commit=False) note_id = self.database.next_id(Note) self.note2 = Note.create(note_id, u"<h3>other title</h3>whee", notebook_id=self.notebook.object_id, user_id=self.user.object_id) self.database.save(self.note2, commit=False)
def test_create_read_write_true_and_own_notes_only_true( self ): notebook = Notebook.create( self.object_id, self.name, trash_id = None, deleted = False, user_id = self.user_id, read_write = True, owner = self.owner, rank = self.rank, own_notes_only = True ) assert notebook.object_id == self.object_id assert datetime.now( tz = utc ) - notebook.revision < self.delta assert notebook.name == self.name assert notebook.trash_id == None assert notebook.deleted == False assert notebook.user_id == self.user_id assert notebook.read_write == Notebook.READ_WRITE_FOR_OWN_NOTES assert notebook.owner == self.owner assert notebook.rank == self.rank assert notebook.tags == [] assert notebook.note_count == None
def test_create_read_write_none( self ): notebook = Notebook.create( self.object_id, self.name, trash_id = None, deleted = False, user_id = self.user_id, read_write = None, owner = self.owner, rank = self.rank ) assert notebook.object_id == self.object_id assert datetime.now( tz = utc ) - notebook.revision < self.delta assert notebook.name == self.name assert notebook.trash_id == None assert notebook.deleted == False assert notebook.user_id == self.user_id assert notebook.read_write == Notebook.READ_WRITE assert notebook.owner == self.owner assert notebook.rank == self.rank assert notebook.tags == [] assert notebook.note_count == None
def convert_post(self, note): # create a notebook thread to go in the forum notebook_id = self.database.next_id(Notebook, commit=False) thread_notebook = Notebook.create( notebook_id, note.title, ) self.database.save(thread_notebook, commit=False) anonymous = self.database.select_one( User, User.sql_load_by_username(u"anonymous")) # move the given note into the newly created notebook thread note.notebook_id = notebook_id note.startup = True note.rank = 0 self.database.save(note, commit=False) # load the forum tag forum_tag = self.database.select_one( Tag, Tag.sql_load_by_name(u"forum", user_id=anonymous.object_id)) # associate the forum tag with the previously created notebook thread, and set that # association's value to the forum name self.database.execute( anonymous.sql_save_notebook_tag(notebook_id, forum_tag.object_id, value=u"blog"), commit=False, ) # give the anonymous user access to the new notebook thread self.database.execute( anonymous.sql_save_notebook(notebook_id, read_write=True, owner=False, own_notes_only=True), commit=False, ) blog_user = self.database.select_one( User, User.sql_load_by_username(self.blog_username)) self.database.execute( blog_user.sql_save_notebook(notebook_id, read_write=True, owner=True), commit=False, )
def convert_post( self, note ): # create a notebook thread to go in the forum notebook_id = self.database.next_id( Notebook, commit = False ) thread_notebook = Notebook.create( notebook_id, note.title, ) self.database.save( thread_notebook, commit = False ) anonymous = self.database.select_one( User, User.sql_load_by_username( u"anonymous" ) ) # move the given note into the newly created notebook thread note.notebook_id = notebook_id note.startup = True note.rank = 0 self.database.save( note, commit = False ) # load the forum tag forum_tag = self.database.select_one( Tag, Tag.sql_load_by_name( u"forum", user_id = anonymous.object_id ) ) # associate the forum tag with the previously created notebook thread, and set that # association's value to the forum name self.database.execute( anonymous.sql_save_notebook_tag( notebook_id, forum_tag.object_id, value = u"blog" ), commit = False, ) # give the anonymous user access to the new notebook thread self.database.execute( anonymous.sql_save_notebook( notebook_id, read_write = True, owner = False, own_notes_only = True ), commit = False, ) blog_user = self.database.select_one( User, User.sql_load_by_username( self.blog_username ) ) self.database.execute( blog_user.sql_save_notebook( notebook_id, read_write = True, owner = True ), commit = False, )
def make_thread(self): title = u"Welcome to the Luminotes %s forum!" % self.forum_name # create a notebook thread to go in the forum notebook_id = self.database.next_id(Notebook, commit=False) thread_notebook = Notebook.create( notebook_id, title, ) self.database.save(thread_notebook, commit=False) anonymous = self.database.select_one( User, User.sql_load_by_username(u"anonymous")) # add a single welcome note to the new thread note_id = self.database.next_id(Note, commit=False) note = Note.create( note_id, u""" <h3>%s</h3> You can discuss any Luminotes %s topics here. This is a public discussion forum, so please keep that in mind when posting. And have fun. """ % (title, self.forum_name), notebook_id, startup=True, rank=0, user_id=anonymous.object_id, creation=datetime.now(), ) self.database.save(note, commit=False) # load the forum tag, or create one if it doesn't exist tag = self.database.select_one( Tag, Tag.sql_load_by_name(u"forum", user_id=anonymous.object_id)) if not tag: tag_id = self.database.next_id(Tag, commit=False) tag = Tag.create( tag_id, notebook_id= None, # this tag is not in the namespace of a single notebook user_id=anonymous.object_id, name=u"forum", description=u"discussion forum threads") self.database.save(tag, commit=False) # associate the forum tag with the previously created notebook thread, and set that # association's value to forum_name self.database.execute( anonymous.sql_save_notebook_tag(notebook_id, tag.object_id, value=self.forum_name), commit=False, ) # give the anonymous user access to the new notebook thread self.database.execute( anonymous.sql_save_notebook(notebook_id, read_write=True, owner=False, own_notes_only=True), commit=False, )
def create_thread(self, user_id): """ Create a new forum thread with a blank post, and give the thread a default name. Then redirect to that new thread. @type user_id: unicode or NoneType @param user_id: id of current logged-in user (if any) @rtype dict @return { 'redirect': new_notebook_url } @raise Access_error: the current user doesn't have access to create a post @raise Validation_error: one of the arguments is invalid """ if user_id is None: raise Access_error() user = self.__database.load(User, user_id) if user is None or not user.username or user.username == "anonymous": raise Access_error() anonymous = self.__database.select_one( User, User.sql_load_by_username(u"anonymous"), use_cache=True) if anonymous is None: raise Access_error() # for now, crappy hard-coding to prevent just anyone from creating a blog thread if self.__name == u"blog" and user.username != u"witten": raise Access_error() # create the new notebook thread thread_id = self.__database.next_id(Notebook, commit=False) thread = Notebook.create(thread_id, self.DEFAULT_THREAD_NAME, user_id=user.object_id) self.__database.save(thread, commit=False) # associate the forum tag with the new notebook thread tag = self.__database.select_one( Tag, Tag.sql_load_by_name(u"forum", user_id=anonymous.object_id)) self.__database.execute( anonymous.sql_save_notebook_tag(thread_id, tag.object_id, value=self.__name), commit=False, ) # give the anonymous user access to the new notebook thread self.__database.execute( anonymous.sql_save_notebook(thread_id, read_write=True, owner=False, own_notes_only=True), commit=False, ) # create a blank post in which the user can start off the thread note_id = self.__database.next_id(Notebook, commit=False) note = Note.create(note_id, u"<h3>", notebook_id=thread_id, startup=True, rank=0, user_id=user_id) self.__database.save(note, commit=False) self.__database.commit() if self.__name == "blog": return dict(redirect=u"/blog/%s" % thread_id, ) return dict(redirect=u"/forums/%s/%s" % (self.__name, thread_id), )
def setUp(self): Test_controller.setUp(self) self.notebook = Notebook.create(self.database.next_id(Notebook), u"my notebook", trash_id=u"foo") self.database.save(self.notebook) self.anon_notebook = Notebook.create(self.database.next_id(Notebook), u"Luminotes", trash_id=u"bar") self.database.save(self.anon_notebook) self.anon_note = Note.create( self.database.next_id(Note), u"<h3>my note</h3>", notebook_id=self.anon_notebook.object_id, ) self.database.save(self.anon_note) self.login_note = Note.create( self.database.next_id(Note), u"<h3>login</h3>", notebook_id=self.anon_notebook.object_id, ) self.database.save(self.login_note) self.username = u"mulder" self.password = u"trustno1" self.email_address = u"*****@*****.**" self.user = None self.session_id = None self.user = User.create(self.database.next_id(User), self.username, self.password, self.email_address) self.database.save(self.user) self.database.execute( self.user.sql_save_notebook(self.notebook.object_id)) self.anonymous = User.create(self.database.next_id(User), u"anonymous") self.database.save(self.anonymous) self.database.execute( self.anonymous.sql_save_notebook(self.anon_notebook.object_id)) self.blog_user = User.create(self.database.next_id(User), u"witten", self.password, self.email_address) self.database.save(self.blog_user) tag_id = self.database.next_id(Tag) self.forum_tag = Tag.create( tag_id, notebook_id= None, # this tag is not in the namespace of a single notebook user_id=self.anonymous.object_id, name=u"forum", description=u"a discussion forum") self.database.save(self.forum_tag) self.general_thread = Notebook.create( self.database.next_id(Notebook), u"Welcome to the general forum!") self.database.save(self.general_thread) self.database.execute( self.anonymous.sql_save_notebook( self.general_thread.object_id, read_write=Notebook.READ_WRITE_FOR_OWN_NOTES), ) self.database.execute( self.anonymous.sql_save_notebook_tag(self.general_thread.object_id, self.forum_tag.object_id, value=u"general"), ) self.support_thread = Notebook.create( self.database.next_id(Notebook), u"Welcome to the support forum!") self.database.save(self.support_thread) self.database.execute( self.anonymous.sql_save_notebook( self.support_thread.object_id, read_write=Notebook.READ_WRITE_FOR_OWN_NOTES), ) self.database.execute( self.anonymous.sql_save_notebook_tag(self.support_thread.object_id, self.forum_tag.object_id, value=u"support"), ) self.blog_thread = Notebook.create(self.database.next_id(Notebook), u"Welcome to the blog!") self.database.save(self.blog_thread) self.database.execute( self.anonymous.sql_save_notebook( self.blog_thread.object_id, read_write=Notebook.READ_WRITE_FOR_OWN_NOTES), ) self.database.execute( self.blog_user.sql_save_notebook(self.blog_thread.object_id, read_write=Notebook.READ_WRITE), ) self.database.execute( self.anonymous.sql_save_notebook_tag(self.blog_thread.object_id, self.forum_tag.object_id, value=u"forum"), )
def setUp( self ): Test_controller.setUp( self ) self.notebook = Notebook.create( self.database.next_id( Notebook ), u"my notebook", trash_id = u"foo" ) self.database.save( self.notebook ) self.anon_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes", trash_id = u"bar" ) self.database.save( self.anon_notebook ) self.anon_note = Note.create( self.database.next_id( Note ), u"<h3>my note</h3>", notebook_id = self.anon_notebook.object_id, ) self.database.save( self.anon_note ) self.login_note = Note.create( self.database.next_id( Note ), u"<h3>login</h3>", notebook_id = self.anon_notebook.object_id, ) self.database.save( self.login_note ) self.username = u"mulder" self.password = u"trustno1" self.email_address = u"*****@*****.**" self.user = None self.session_id = None self.user = User.create( self.database.next_id( User ), self.username, self.password, self.email_address ) self.database.save( self.user ) self.database.execute( self.user.sql_save_notebook( self.notebook.object_id ) ) self.anonymous = User.create( self.database.next_id( User ), u"anonymous" ) self.database.save( self.anonymous ) self.database.execute( self.anonymous.sql_save_notebook( self.anon_notebook.object_id ) ) self.blog_user = User.create( self.database.next_id( User ), u"witten", self.password, self.email_address ) self.database.save( self.blog_user ) tag_id = self.database.next_id( Tag ) self.forum_tag = Tag.create( tag_id, notebook_id = None, # this tag is not in the namespace of a single notebook user_id = self.anonymous.object_id, name = u"forum", description = u"a discussion forum" ) self.database.save( self.forum_tag ) self.general_thread = Notebook.create( self.database.next_id( Notebook ), u"Welcome to the general forum!" ) self.database.save( self.general_thread ) self.database.execute( self.anonymous.sql_save_notebook( self.general_thread.object_id, read_write = Notebook.READ_WRITE_FOR_OWN_NOTES ), ) self.database.execute( self.anonymous.sql_save_notebook_tag( self.general_thread.object_id, self.forum_tag.object_id, value = u"general" ), ) self.support_thread = Notebook.create( self.database.next_id( Notebook ), u"Welcome to the support forum!" ) self.database.save( self.support_thread ) self.database.execute( self.anonymous.sql_save_notebook( self.support_thread.object_id, read_write = Notebook.READ_WRITE_FOR_OWN_NOTES ), ) self.database.execute( self.anonymous.sql_save_notebook_tag( self.support_thread.object_id, self.forum_tag.object_id, value = u"support" ), ) self.blog_thread = Notebook.create( self.database.next_id( Notebook ), u"Welcome to the blog!" ) self.database.save( self.blog_thread ) self.database.execute( self.anonymous.sql_save_notebook( self.blog_thread.object_id, read_write = Notebook.READ_WRITE_FOR_OWN_NOTES ), ) self.database.execute( self.blog_user.sql_save_notebook( self.blog_thread.object_id, read_write = Notebook.READ_WRITE ), ) self.database.execute( self.anonymous.sql_save_notebook_tag( self.blog_thread.object_id, self.forum_tag.object_id, value = u"forum" ), )
def setUp(self): Test_controller.setUp(self) self.notebook = Notebook.create(self.database.next_id(Notebook), u"my notebook", trash_id=u"foo") self.database.save(self.notebook) self.anon_notebook = Notebook.create(self.database.next_id(Notebook), u"Luminotes") self.database.save(self.anon_notebook) self.anon_note = Note.create( self.database.next_id(Note), u"<h3>my note</h3>", notebook_id=self.anon_notebook.object_id, ) self.database.save(self.anon_note) self.login_note = Note.create( self.database.next_id(Note), u"<h3>login</h3>", notebook_id=self.anon_notebook.object_id, ) self.database.save(self.login_note) self.blog_notebook = Notebook.create(self.database.next_id(Notebook), u"Luminotes blog") self.database.save(self.blog_notebook) self.blog_note = Note.create( self.database.next_id(Note), u"<h3>my blog entry</h3>", notebook_id=self.blog_notebook.object_id, ) self.database.save(self.blog_note) self.guide_notebook = Notebook.create(self.database.next_id(Notebook), u"Luminotes user guide") self.database.save(self.guide_notebook) self.guide_note = Note.create( self.database.next_id(Note), u"<h3>it's all self-explanatory</h3>", notebook_id=self.guide_notebook.object_id, ) self.database.save(self.guide_note) self.privacy_notebook = Notebook.create( self.database.next_id(Notebook), u"Luminotes privacy policy") self.database.save(self.privacy_notebook) self.privacy_note = Note.create( self.database.next_id(Note), u"<h3>yay privacy</h3>", notebook_id=self.privacy_notebook.object_id, ) self.database.save(self.privacy_note) self.username = u"mulder" self.password = u"trustno1" self.email_address = u"*****@*****.**" self.user = None self.session_id = None self.user = User.create(self.database.next_id(User), self.username, self.password, self.email_address) self.database.save(self.user) self.database.execute( self.user.sql_save_notebook(self.notebook.object_id)) self.anonymous = User.create(self.database.next_id(User), u"anonymous") self.database.save(self.anonymous) self.database.execute( self.anonymous.sql_save_notebook(self.anon_notebook.object_id, read_write=False, owner=False, rank=0)) self.database.execute( self.anonymous.sql_save_notebook(self.blog_notebook.object_id, read_write=False, owner=False, rank=1)) self.database.execute( self.anonymous.sql_save_notebook(self.guide_notebook.object_id, read_write=False, owner=False, rank=2)) self.database.execute( self.anonymous.sql_save_notebook(self.privacy_notebook.object_id, read_write=False, owner=False, rank=3))