Peter's Blog 8.5.2004

2004-05-08

Old Blog Uploaded

I hacked up a Python script to merge my old blog with my new Python Desktop Server blog. It uses the PyDS MetaWeblogAPI. The script is here. Not pretty but it's something. It reads entries from my Natara DayNotez database, sees if they are already in the PyDS blog and if they are not it posts them. I had to make a small change to PyDS to give the posts the correct creation date. To do this I added one line to MetaWeblogAPI.py:

id = weblog.postNewEntry(
   
struct.get('title',''),
   
struct.get('link',''),
   
struct.get('description',''),
   
struct.get('source',{}).get('name',''),
   
struct.get('source',{}).get('url',''),
   
onhome=publish and not(struct.get('flNotOnHomePage',0)),
   
# PCW: allow published time to be specified.
   
pubtime=int(struct.get('pubtime', '0')),
   
categories=categories,
   
structured=structured)
return id

Uploading wentsmoothly after one tricky problem. The £ character caused problems with XML. I eventually got around this by converting the title and description fields to unicode before posting:

oPost['title'] = unicode( strTitle, 'ISO-8859-1')
oPost['description'] = unicode( strRtxNote, 'ISO-8859-1')

I fixed my vim posting script in the same way.

posted at 17:08:32    #    comment []    trackback []
May 2004
MoTuWeThFrSaSu
      1 2
3 4 5 6 7 8 9
10111213141516
17181920212223
24252627282930
31      
Apr
2004
 Jun
2004

A blog documenting Peter's dabblings with Python, Gentoo Linux and any other cool toys he comes across.

XML-Image Letterimage

© 2004, Peter Wilkinson

Bisi and me