def post(self, page_name): content = self.request.get('content') parent = utils.wiki_key() w = Wiki(parent = parent, name = page_name, content = content) add_wiki(w) self.redirect(page_name)
def post(self, page_name): content = self.request.get('content') parent = utils.wiki_key() w = Wiki(parent=parent, name=page_name, content=content) add_wiki(w) self.redirect(page_name)
def get(self, page_name): # if version requested, return appropriate wiki version version = self.request.get('v', '') logging.error('WIKI VERSION REQUEST = ' + version) #MEMCACHED DISABLED wiki = '' wiki_key = '' # wiki_key = 'WIKI_' + page_name # wiki, age = utils.age_get(wiki_key) #if wiki not returned by memcached, lookup from db if not wiki: #get wiki from db via gql query if version != '': wiki = Wiki.get_by_id(int(version), utils.wiki_key()) logging.error("WIKI GET_BY_ID = " + repr(wiki)) else: query = Wiki.gql( "WHERE name =:page_name ORDER BY created desc LIMIT 1", page_name=page_name) wikis = query.fetch(limit=1) if len(wikis) > 0: wiki = wikis[0] if wiki: utils.age_set(wiki_key, wiki) age = 0 #if wiki exists, render WikiPage if wiki: self.params['wiki'] = wiki self.params['age'] = utils.age_str(age) self.render("wiki-page.html") #if wiki doesn't exist and user is logged in, redirect to WikiEdit.py elif not wiki and self.user: self.redirect('/_edit%s' % page_name) return #if url doesn't exist and user is NOT logged in, redirect to login else: self.redirect('/login')
def get(self, page_name): # if version requested, return appropriate wiki version version = self.request.get('v', '') logging.error('WIKI VERSION REQUEST = ' + version) #MEMCACHED DISABLED wiki = '' wiki_key = '' # wiki_key = 'WIKI_' + page_name # wiki, age = utils.age_get(wiki_key) #if wiki not returned by memcached, lookup from db if not wiki: #get wiki from db via gql query if version != '': wiki = Wiki.get_by_id(int(version), utils.wiki_key()) logging.error("WIKI GET_BY_ID = " + repr(wiki)) else: query = Wiki.gql("WHERE name =:page_name ORDER BY created desc LIMIT 1", page_name = page_name) wikis = query.fetch(limit=1) if len(wikis) > 0: wiki = wikis[0] if wiki: utils.age_set(wiki_key, wiki) age = 0 #if wiki exists, render WikiPage if wiki: self.params['wiki'] = wiki self.params['age'] = utils.age_str(age) self.render("wiki-page.html") #if wiki doesn't exist and user is logged in, redirect to WikiEdit.py elif not wiki and self.user: self.redirect('/_edit%s' % page_name) return #if url doesn't exist and user is NOT logged in, redirect to login else: self.redirect('/login')