def submitnewthread(self): thread = model.Thread() thread.subject = request.POST['subject'] post = model.Post() post.author =users.get_current_user(self) post.isparent = True post.content = request.POST['content'] thread.posts.append(post) #adding post to the thread object meta.Session.add(thread) #look only have to add the thread object meta.Session.flush() #optional when AutoCommit is on, but useful for control in data integrity cases meta.Session.commit() #makes changes real thread_query = meta.Session.query(model.Thread) #query back submitted data to display to ui thread = thread_query.filter_by(id=thread.id).first() # yes actually querying using the thread id of our created object above c.username = thread.posts[0].author c.subject = thread.subject c.content = thread.posts[0].content return render('submitnewthread.mako')
def newthread(self): return render('newthread.mako')
def index(self): c.username = "******" # c.posts = [Post("jkruse", "New Kindle", "06/24/2009")] thread_query = meta.Session.query(model.Thread) c.threads = thread_query.order_by(model.Thread.dateadded.desc()).limit(5).all() return render('index.mako')