def publish(self): regenerate = False; if not self.path: num = 0; content = None; while not content: path = utils.format_page_path(self, num); content = static.add(path, '', config.html_mime_type); num += 1; self.path = path; self.put(); # Force regenerate on new publish. Also helps with generation of # chronologically previous and next page. regenerate = True; # force refresh of cache, before dependencies are run utils.clear_page_memoizer_cache(self); for generator_class, deps in self.get_deps(regenerate=regenerate): for dep in deps: if generator_class.can_defer: deferred.defer(generator_class.generate_resource, None, dep); else: generator_class.generate_resource(self, dep); self.put();
def post(self, post): form = PageForm(data=self.request.POST) if form.is_valid(): post = form.save(commit=False) post.path = utils.format_page_path(post) page_key = post.path[len(config.page_path):] """construct a new PagePost for persistence""" content = models.PagePost( key_name=page_key, path=post.path, title=post.title, body=post.body) content.put() memcache.replace(page_key, db.model_to_protobuf(content).Encode()) self.render_to_response("published.html", "admin", {'post': post}) else: self.render_form(form)
def post(self, post): form = PageForm(data=self.request.POST) if form.is_valid(): post = form.save(commit=False) post.path = utils.format_page_path(post) page_key = post.path[len(config.page_path):] """construct a new PagePost for persistence""" content = models.PagePost(key_name=page_key, path=post.path, title=post.title, body=post.body) content.put() memcache.replace(page_key, db.model_to_protobuf(content).Encode()) self.render_to_response("published.html", "admin", {'post': post}) else: self.render_form(form)