From squishdot to quillsΒΆ

Tags: quills, plone

I copy/pasted an existing piece of migration code out of Quills and modified it for my needs - and stuck it into the the installer for the product I'm using to store my templates and so in:

    def _createWeblogEntry(quills, id, oldid, title, desc, publishDate,
                           urldate, text, topics):
        new_obj = getattr(quills, id)
        new_obj.setContentType('text/structured', key='text')
        #wft = getToolByName(self, 'portal_workflow')
        #wft.doActionFor(new_obj, 'publish')
        out.write("Added blog entry %s.\n" % id)
        out.write("apache: %s => archive/%s/%s.\n" % (oldid, urldate, id))

    def migrateSquishdot(portal):
        # These are some values that are used to create
        # the Quills weblog
        quillsBlog = 'weblog'
        quillsTitle = 'Weblog'
        path = quillsBlog + '/drafts/'

        # Create the blog based on the values set above
        if hasattr(portal, quillsBlog):
            out.write("Quills log already exists, deleting it again.\n")
        portal.invokeFactory('Weblog', id=quillsBlog, title=quillsTitle)
        newblog = getattr(portal, quillsBlog)

        target = portal.restrictedTraverse(path)
            oldblog = portal.oldweblog
            out.write("Can't find old weblog, quitting.\n")
        qtool = portal.quills_tool

        for entry in
            title = entry.title
            desc = ''
            body1 = '\n'.join(entry.summary)
            body2 = '\n'.join(entry.body)
            body = '\n'.join([body1, body2])
            oldid =
            id = qtool.idFromTitle(title, 'WeblogEntry', newblog)

            # Using the '%c' stftime was the only way I could
            # successfully migrate the effective time
            ltime = localtime(entry.created)
            date= strftime('%c', ltime)
            urldate = strftime('%Y/%m/%d', ltime)
            # Make sure we don't have the topic already, then add it
            oldBlogCat = entry.subject
            quillsTopic = qtool.idFromTitle(oldBlogCat, 'WeblogTopic', newblog)
            if quillsTopic not in [blogTopic.getId() for blogTopic in
                                   newblog.getTopics() ]:
                out.write("Added topic '%s'.\n" % quillsTopic)
            _createWeblogEntry(target, id, oldid, title, desc, date,
                               urldate, body, [quillsTopic])

Note that I moved the old weblog over to /weblog_old/ for the time being so that I could create the quills weblog directly into a fresh new /weblog. logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):