def metaWeblog_editPost(postid, struct, publish): if struct.has_key('categories'): cates = struct['categories'] else: cates = [] newcates=[] for cate in cates: c=Category.all().filter('name =',cate).fetch(1) if c: newcates.append(c[0].key()) entry=Entry.get_by_id(int(postid)) 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'] try: if struct.has_key('date_created_gmt'): #如果有日期属性 entry.date=datetime.strptime(str(struct['date_created_gmt']), "%Y%m%dT%H:%M:%S") elif struct.has_key('dateCreated'): #如果有日期属性 entry.date=datetime.strptime(str(struct['dateCreated']), "%Y%m%dT%H:%M:%S")-timedelta(seconds=3600*g_blog.timedelta) except: pass if struct.has_key('wp_password'): entry.password=struct['wp_password'] if struct.has_key('sticky'): entry.sticky=struct['sticky'] if struct.has_key('wp_author_id'): author=User.get_by_id(int(struct['wp_author_id'])) entry.author=author.user entry.author_name=author.dispname else: entry.author=g_blog.owner entry.author_name=g_blog.author entry.title = struct['title'] entry.content = struct['description'] if struct.has_key('mt_text_more'): content=struct['mt_text_more'] if content: entry.content=entry.content+"<!--more-->"+struct['mt_text_more'] entry.categorie_keys=newcates if publish: entry.save(True) else: entry.save() return True
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'] try: if struct.has_key('date_created_gmt'): #如果有日期属性 entry.date=datetime.strptime(str(struct['date_created_gmt']), "%Y%m%dT%H:%M:%S") elif struct.has_key('dateCreated'): #如果有日期属性 entry.date=datetime.strptime(str(struct['dateCreated']), "%Y%m%dT%H:%M:%S")-timedelta(seconds=3600*g_blog.timedelta) except: pass 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']) if struct.has_key('wp_password'): entry.password=struct['wp_password'] if struct.has_key('wp_author_id'): author=User.get_by_id(int(struct['wp_author_id'])) entry.author=author.user entry.author_name=author.dispname else: entry.author=g_blog.owner entry.author_name=g_blog.author entry.entrytype='page' if publish: entry.save(True) else: entry.save() postid =entry.key().id() return str(postid)
def wp_editPage(blogid,pageid,struct,publish): entry=Entry.get_by_id(int(pageid)) ## if struct.has_key('mt_keywords'): ## entry.tags=struct['mt_keywords'].split(',') 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']) try: if struct.has_key('date_created_gmt'): #如果有日期属性 entry.date=datetime.strptime(str(struct['date_created_gmt']), "%Y%m%dT%H:%M:%S") elif struct.has_key('dateCreated'): #如果有日期属性 entry.date=datetime.strptime(str(struct['dateCreated']), "%Y%m%dT%H:%M:%S")-timedelta(seconds=3600*g_blog.timedelta) except: pass if struct.has_key('wp_password'): entry.password=struct['wp_password'] if struct.has_key('wp_author_id'): author=User.get_by_id(int(struct['wp_author_id'])) entry.author=author.user entry.author_name=author.dispname else: entry.author=g_blog.owner entry.author_name=g_blog.author entry.title = struct['title'] entry.content = struct['description'] if struct.has_key('mt_text_more'): entry.content=entry.content+"<!--more-->"+struct['mt_text_more'] entry.save(True) return True
def dateformat(creatdate): try: dt=datetime.strptime(creatdate, "%Y%m%dT%H:%M:%S") except: dt=datetime.strptime(creatdate, "%Y%m%dT%H:%M:%SZ") return dt
def dateformat(creatdate): try: dt = datetime.strptime(creatdate, "%Y%m%dT%H:%M:%S") except: dt = datetime.strptime(creatdate, "%Y%m%dT%H:%M:%SZ") return dt
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'] try: if struct.has_key('date_created_gmt'): #如果有日期属性 entry.date=datetime.strptime(str(struct['date_created_gmt']), "%Y%m%dT%H:%M:%S") elif struct.has_key('dateCreated'): #如果有日期属性 entry.date=datetime.strptime(str(struct['dateCreated']), "%Y%m%dT%H:%M:%S")-timedelta(seconds=3600*g_blog.timedelta) except: pass if struct.has_key('wp_password'): entry.password=struct['wp_password'] if struct.has_key('sticky'): entry.sticky=struct['sticky'] if struct.has_key('wp_author_id'): author=User.get_by_id(int(struct['wp_author_id'])) entry.author=author.user entry.author_name=author.dispname else: entry.author=g_blog.owner entry.author_name=g_blog.author if publish: entry.save(True) if struct.has_key('mt_tb_ping_urls'): for url in struct['mt_tb_ping_urls']: util.do_trackback(url,entry.title,entry.get_content_excerpt(more='')[:60],entry.fullurl,g_blog.title) g_blog.tigger_action("xmlrpc_publish_post",entry) else: entry.save() postid =entry.key().id() return str(postid)