Random ...
 
December 2017
S M T W T F S
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Tags ...
Links



python+zope++:: Exporting COREBlog entries to Bitakora
Posted at 30.Jul,2006 14:25  Comments 4 / Trackbacks 0 / Like this post!
Technorati tag(s):

So you want to move to Bitakora from COREBlog. But you have many entries and don't want to lose them?

Don't fret. Bitakora can import those entries. The problem is, we need to have those entries in xml, as specified by Bitakora import.txt

Go to your COREBlog instance and create a Script (Python):

 msj= """<?xml version="1.0" encoding="UTF-8"?>
 <posts>
 """

 for i in container.rev_entry_items(start=0,count=100):
  msj+= """ <post>
   <author> %s </author>
   <title><![CDATA[ %s  ]]></title>
   <date>  %s  </date>
   <body><![CDATA[ %s   ]]></body>
   <tags><![CDATA[   ]]></tags>
   <comments>
    """ % (i.author,i.title, i.date_created().strftime('%d/%b/%Y %H:%M'),i.rendered_body)
  if len(i.comments):
    for c in i.comment_list():
      msj += """   
     <comment>
       <author><![CDATA[  %s ]]> </author>
       <date>  2006/07/29 </date>
       <body><![CDATA[ %s   ]]></body>
       <url><![CDATA[ %s  ]]></url>
       <email><![CDATA[ %s  ]]></email>
     </comment>
     """ % (c.author,c.body,c.url,c.email)
  msj+="""</comments>
    </post>
    """
 msj += '</posts>'

 print msj
 return printed

Test the script and you'll get the entries in a format Bitakora understands.

Now, go to your Bitakora instance/admin, and find prefs tab. At the end of the page, import your entries.

One snag. I can't seem to get comment created_date. It always raise an unauthorized error. Haven't yet looked at it. It's the weekend! Probably an External Method will work. Oh, and another. If you use restructered text, you wont get a rendered html. :(


Bookmark and Share

Is this entry helpful? Comments/Donate/Click some google ads.  
Trackback is http://myzope.kedai.com.my/blogs/kedai/93/tbping 

Comments

Woot!

We used to have our COREBlog posts in structured text and instead of using rendered_html you can use body and convert to HTML using::

from Products.PythonScripts.standard import structured_text

structured_text(i.body)

I think that with reStructured text something similar can be done.

Regards,

Mikel
Bitakora author :P

erral  at 31.Aug,2006 18:30
thanks for the tip

will try it soon. btw - it seems that bitakora is taking the back seat? no new release?

kedai  at 03.Sep,2006 12:13
Yes....

Well, now we are very busy with other projects (Plone) but we have some ideas to improve Bitakora specially regarding comment spam and so on.

Also, I have some ideas to start using Five and Zope3 technologies and get rid of some very ugly things I've done in Bitakora ;)

I also hope to have a public SVN server with Bitakora code, we'll have it sooner than later :)

erral  at 08.Sep,2006 17:00
public svn

is cool. hope i can contribute somehow.

:)

kedai  at 08.Sep,2006 19:24
Post a comment