def __init__(self, app): bmodel = BlogModel() bview = BlogFeedView() form = Form() art = Article() if app.request.GET: # On submit of the form. The info is stored in the self.the_posted object self.the_post = {} self.the_post["title"] = app.request.GET["title"] self.the_post["author"] = app.request.GET["author"] self.the_post["tags"] = app.request.GET["tags"] self.the_post["category"] = app.request.GET["category"] self.the_post["article"] = app.request.GET["article"] self.the_post["date"] = (time.strftime("%m/%d/%Y")) # Pass the post object into the format method art.a() to return a string html. # Then add the the global log_post array to the add_post_list so that the post will be append to it. bmodel.add_post_list(art.a(self.the_post), log_posts) # This will then write the response to the browser after the full html document is returned. app.response.write(bview.form_success(bmodel.formator(log_posts), form.reg_form)) else: # If no submission display form only to the browser. app.response.write(bview.print_out_form(form.reg_form))
from blogmodel import BlogModel blog = BlogModel("testblog.db") blog.insert("A title","Some words") print blog.read(1) blog.close()