def post(self): content = self.request.get('content').replace('\n', '') username = loginHandler.get_user_name(self) item = get_wiki_item_name(self) #for front page global hash_of_words global queue_of_words global queue_length if not (item in hash_of_words): if (queue_of_words.qsize() >= 100): queue_of_words.dequeue() queue_of_words.put(item) hash_of_words.add(item) logging.debug("queue finished") if memcache.get(item): logging.debug("update a existing item in wiki, item = " + item) wiki_entry = db.GqlQuery("select * from wiki_info where item = :1", item) wiki_entry.wiki_content = content wiki_entry = wiki_entry.get() #update content in db wiki_entry.put() else: logging.debug("create a new item in wiki, item =" + item) p = wiki_info(username = username, wiki_content = content, item = item) p.put() memcache.set(item, (username, content)) #use memcache to update this item #add current item to user history page h = history_info(username = username, item = item, content = content) h.put() self.redirect('/wiki/' + item)
def get(self): user_logged_in_stat = loginHandler.get_user_logging_status() item = get_wiki_item_name(self) if user_logged_in_stat: username = loginHandler.get_user_name(self) tup = get_content(item) content = "" #default is empty value if tup[1]: content = tup[1] self.render("wiki_post_page.html", item = item, content = content, username = username, user_logged_in_stat = user_logged_in_stat) else: self.render('/wiki/login') #redirect to the front page