def get(self): '''Provides form for new post''' username = authentication.getUserName(self) if username: self.render('blog_newpost.html', title='', content='', error='', username=username) else: self.redirect('/login?redirect=%s'%self.request.url)
def get(self, link): username = authentication.getUserName(self) if username: if link in ['_edit', '_history']: # easter egg self.redirect('/wiki/meta') return id = self.request.get('history') # Edit wiki = get_wiki(link, id = id, handler=self) title = wiki.title if wiki else link.capitalize() content = wiki.content if wiki else '' url = link version = wiki.key().id() if wiki else '' self.render('wiki_edit.html', title=title, content = content, url = link, version = version) else: self.redirect('/login?redirect=%s'%self.request.url)
def post(self): '''Creates a new post''' username = authentication.getUserName(self) if username: title = self.request.get('subject') content = self.request.get('content') if title and content: p = BlogPost(title = title, content = content, author = username) p.put() id = str(p.key().id()) get_single(id) # Fill memcache update_all() self.redirect("/blog/p/"+id) else: error = 'Both title and content are required!' self.render('blog_newpost.html', title = title, content = content, error = error, username = username) else: self.redirect('/login?redirect=%s'%self.request.url)
def post(self, link): username = authentication.getUserName(self) if username: title = self.request.get('title') if not title: title = link content = self.request.get('content') version = self.request.get('version') if title and content: wiki = WikiPage(title=title, content=content, url=link, author=username) logging.warning('Inserting WikiPage url: %s'%link) wiki.put() get_wiki(link, update=True) get_history(link, update=True) self.redirect('/wiki/%s'%link) else: error = 'Both title and content are required!' self.render('wiki_edit.html', title=title, content = content, url = link, error=error, version = version) else: self.redirect('/login?redirect=%s'%self.request.url)
def render(self, template, **kw): '''Render using the template and parameters''' username = authentication.getUserName(self) self.write(self.render_str(template, _user=username, _url=self.request.url, **kw))
def get(self): username = authentication.getUserName(self) if username: self.render('welcome.html', name=username) else: self.redirect('/login')