# -*- coding: utf-8 -*- import config from RemoteWP import RemoteWP from datetime import datetime blog = RemoteWP(config.serviceUrl, config.usr, config.passwd) # blog.newPost(title='Post RPC', description='Un post da remoto, col Pitone', categories=('Inserimenti remoti',), mt_keywords='xml, tags, prova', publish=False, dateCreated=datetime.strptime('20090417T08:43:12', '%Y%m%dT%H:%M:%S')) # blog.newCategory(name='Inserimenti remoti', slug='inserimenti_remoti', description='Categorie di test per gli inserimenti remoti, da XMLRPC') # blog.newComment(14, content='Un thread', author='Guglielmo Celata', author_email='*****@*****.**', author_url='http://guglielmo.celata.com', comment_parent_id=3) # blog.editComment(7, author='Guglielmo', status='hold') # blog.editComment(7, status='approve') print "categorie" print "=========" blog.list_categories() print "post" print "====" blog.list_posts()
# -*- coding: utf-8 -*- import config from RemoteWP import RemoteWP from time import sleep import MySQLdb from datetime import datetime from os import sys blog = RemoteWP(config.serviceUrl, config.usr, config.passwd) # connessione al DB con charset utf8, per non avere problemi con gli accenti # http://tahpot.blogspot.com/2005/06/mysql-and-python-and-unicode.html db = MySQLdb.connect("localhost","root","","op_openparlamento", init_command='SET NAMES utf8') cursor = db.cursor(MySQLdb.cursors.DictCursor) p_cursor = db.cursor(MySQLdb.cursors.DictCursor) # creazione categoria openparlamento blog.newCategory(name='Openparlamento', slug='openparlamento', description='Post che riguardano il progetto openparlamento') # estrazione dei post da opp posts_sql = "select * from sf_blog_post where is_published=1 order by published_at, created_at asc" cursor.execute(posts_sql) p_result_set = cursor.fetchall() for p in p_result_set: print "%s, %s, %s" % (p['id'], p["title"], p["published_at"]) # estrazione tag tags_sql = "select * from sf_blog_tag where sf_blog_post_id=%s" p_cursor.execute(tags_sql, (p['id'])) t_result_set = p_cursor.fetchall()