You are here: Home / Documentation / How To's / Script to convert Quills blog posts to Plone pages ("Documents")

Script to convert Quills blog posts to Plone pages ("Documents")

by nguyen — published Nov 30, 2013 08:45 PM, last modified Aug 16, 2016 10:50 AM

In the ZMI add a Script (Python) called ".convert" with this code:

# Example code:

# Import a standard function, and get the HTML request and response objects.
from Products.PythonScripts.standard import html_quote
request = container.REQUEST

#return "container is ",

# # Return a string identifying this script.
# print "This is the", script.meta_type, '"%s"' % script.getId(),
# if script.title:
#     print "(%s)" % html_quote(script.title),
# print "in", container.absolute_url()

#print container.contentItems()
#print [i for i in container.contentItems() if i[1].meta_type == 'WeblogEntry']
#blog_entries = [i for i in container.contentItems() if i[1].meta_type == 'WeblogEntry']
#print len([i for i in container.contentItems() if i[1].meta_type == 'WeblogEntry'])

#container.invokeFactory("ATFolder", id="newblog")
newblog = container['newblog']

#return blog_entries[0]

for blogentry_tuple in [i for i in container.contentItems() if i[1].meta_type == 'WeblogEntry']:
    blogentry = blogentry_tuple[1]
    #print "blog entry '",, "'has title '", blogentry.Title(), "', summary '", blogentry.description(), "', body '", blogentry.getText(), "', keywords '", blogentry.Subject(), "', contributors '", blogentry.Contributors(), "', creators '", blogentry.Creators(), "', effective date ", blogentry.getEffectiveDate(), "', creation date ", blogentry.created(), "', last modification date ", blogentry.modified(), "', expiration date ", blogentry.getExpirationDate()
    newblog.invokeFactory("Document",, title=blogentry.Title())
    newblogentry = newblog[]
    print "blog entry '",, "'has title '", blogentry.Title(), "' converted"
#    return printed

return printed

Before Running the Script

Before you run it, create a sibling Folder with ID "newblog".  The script will create a Plone Document with the same ID, title, and other metadata for each Quills WeblogEntry object in the current folder.

After Running the Script

Export and Import

You can then use the ZMI to export the "newblog" folder and import the resulting "newblog.zexp" into another site.  

You may also want to export the "uploads" and "topic_images" folders in the Quills blog folder and import those into the new site's "newblog" folder.

Migrate BTrees

On the destination site, you may need to run the "/@@migrate-btrees" view to convert Plone 3.x ATFolder objects to the new BTree ATFolder in Plone 4.x. 

Reindex Catalog

On the destination site you will also want to go to the ZMI -> portal_catalog -> Advanced tab -> Clear and Rebuild button to index the new pages.

Publish All the Converted Pages

If you want to publish all the converted pages ("Documents"), you can run the companion Script to publish all pages in a folder