def create_post(form): """ Creates and saves a new post. When a post is created, it's put at cache (by key) and the cache for all posts/drafts is cleaned. """ slug = slugify(form["slug"]) if (len(form["slug"]) > 0) else slugify(form["title"]) tags = __strip_tags(form["tags"].split(",")) if (len(form["tags"]) > 0) else [] striped = strip_html_code(form["content"]) desc = form["desc"] as_draft = form.has_key("draft") html = bbcode_to_html(striped) post = Post( title=form["title"], slug=slug, tags=tags, desc=desc, author=users.get_current_user(), coded_content=striped, html_content=html, as_draft=as_draft, ) post.put() memcache.set(str(post.key()), post) memcache.delete_multi(["all_posts_10", "all_drafts_10"]) update_sitemap() twit_post(str(post.key())) return post
def publish_draft(key): """ Removes 'as_draft' mark from the post with the given key Cache adjusted """ draft = get_post_by_key(key) draft.as_draft = False draft.put() memcache.delete_multi(["all_posts_10", "all_drafts_10", str(draft.key())]) twit_post(str(draft.key()))