Upgrading Plone 2 to 5, a different approach(?)

Just want to share some info, in case it could be relevant for others:

  • I am looking into the possibility of upgrading a VERY old Plone site (2.5, but started on 2.0) that has been running 'unchanged since 2007
  • I do not want to 'touch anything', and since installing Python 2.4 failed I tried this approach:
  1. I made smart folders for the different content types I wanted to export, in the example below 'Book'. Note: the template could probably been simpler, but I used an existing:

                    define="contentFilter    contentFilter|request/contentFilter|nothing;
                    limit_display    limit_display|request/limit_display|nothing;
                    more_url         more_url|request/more_url|string:folder_contents;
                    contentsMethod   python:test(here.portal_type=='Topic', here.queryCatalog, here.getFolderContents);
                    folderContents   folderContents|python:contentsMethod(contentFilter, batch=True);
                    use_view_action  site_properties/typesUseViewActionInListings|python:();
                    over_limit       python: limit_display and len(folderContents) > limit_display;
                    folderContents   python: (over_limit and folderContents[:limit_display]) or folderContents;
                    batch            folderContents">
                    <tal:listing condition="folderContents">
                    <div tal:repeat="item folderContents">
                        <tal:block tal:define="here item/getObject" tal:on-error="nothing">  
                       <div metal:use-macro="here/my_book_view/macros/main"/>
  2. I then made the macro for the different content types. In this case the 'Book'.

     <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"
         <div metal:fill-slot="main">
           <div metal:define-macro="main">
             """id""":   """<div tal:replace="here/id" />""", 
             """beskrivelse""": """<p tal:replace="here/description" />""",
             """richtext""": u"""<p tal:replace="here/richtext" />""",
             """priceGross""" : """<p tal:replace="here/priceGross" />""", 
             .... more fields here
             """image""" : """<p tal:replace="python:here.absolute_url()" />/image""", 
  3. I used the views on the smart folders (for example http:// mysite \ .com/smartfolder1/my_export_view

  4. This would give me a 'long list of items, which I copied into a script. In fact, I just added it to my profile (setuphandlers.py). After installing the add-on, the content is present. I had just one issue, a paragraph that ended with ", so I added a space after it.

  5. The script then looks like this

     def _create_content(portal):
         """Lets create the content"""
         kontent = [ {"id"="""xx""", 
                             "title" = """yy""", 
                             "richtext" =  u"""something""",
                             "image"  = """somepath"""",
                             .... rest of pasted content here.
       for i in kontent:
           if not portal.get(i, False):
           book = api.content.create(
               shortdescription = RichTextValue(i['shortDescription'], 'text/html', 'text/x-html-safe'),
               .... etc. 
           book.image = url_load_image(i['image'], i['id'])
     def url_load_image(url, title):
         response = requests.get(url)
         img = Image.open(BytesIO(response.content))
         return NamedBlobImage(
             data=open('something.jpg', 'rb').read(),

NOTE: I did not figure out how to 'read the image data directly from the old site (that is why I save it first), so if you use PNG or GIF images you might get an error.

1 Like
     return NamedBlobImage(


Thanks, that works.

PS: The errors I got was because the images from 'not published content' is not readable, while the list I got from the view included those.

1 Like

Plone Foundation Code of Conduct