def metaWeblog_newPost(blogid, struct, publish): if struct.has_key('categories'): cates = struct['categories'] else: cates = [] newcates = [] for cate in cates: c = Category.all().filter('name =', cate) if c: newcates.append(c[0].key()) entry = Entry(title=struct['title'], content=struct['description'], categorie_keys=newcates) if struct.has_key('mt_text_more'): content = struct['mt_text_more'] if content: entry.content = entry.content + '<!--more-->' + struct['mt_text_more'] if struct.has_key('mt_keywords'): entry.settags(struct['mt_keywords']) if struct.has_key('wp_slug'): entry.slug = struct['wp_slug'] if struct.has_key('mt_excerpt'): entry.excerpt = struct['mt_excerpt'] if struct.has_key('mt_tags'): tags = struct['mt_tags'] else: tags = [] entry.settags(tags) if struct.has_key('dateCreated'): strDate = struct['dateCreated'].__str__(); strZ = '' if (strDate[-1] == 'Z'): strZ = 'Z' entry.date = datetime.strptime(strDate, '%Y%m%dT%H:%M:%S' + strZ) if publish: entry.publish(True) else: entry.save() postid = entry.key().id() return str(postid)
def wp_newPage(blogid, struct, publish): entry = Entry(title=struct['title'], content=struct['description']) if struct.has_key('mt_text_more'): entry.content = entry.content + '<!--more-->' + struct['mt_text_more'] if struct.has_key('wp_slug'): entry.slug = struct['wp_slug'] if struct.has_key('wp_page_order'): entry.menu_order = int(struct['wp_page_order']) entry.entrytype = 'page' if publish: entry.publish(True) else: entry.save() postid = entry.key().id() return str(postid)