def get(self, path): v = self.request.get('v') p = None age = None if v: if v.isdigit(): page_key = 'PAGE_' + path + v p, age = age_get(page_key) if not p: p = Page.by_id(int(v), path) age_set(page_key, p) age = 0 if not p: return self.notfound() else: page_key = 'PAGE_' + path p, age = age_get(page_key) if not p: p = Page.by_path(path).get() age_set(page_key, p) age = 0 self.done(page = p, path = path, age = age_str(age))
def post(self, path): if not self.user: self.error(400) return content = self.request.get('content') author = self.user.name old_page = Page.by_path(path).get() if not(old_page or content): return elif not old_page or old_page.content != content: p = Page(parent = Page.parent_key(path), content = content, author = author) add_page(path, p) page_key = 'PAGE_' + path age_set(page_key, p) self.redirect('/wiki' + path)