[Product-Developers] migrating portlets from 2.5 to 3

Joe Bigler jeb6 at psu.edu
Sun Mar 20 23:47:29 UTC 2011


I was able to find a way to clear the values in all the slots.  I created a
python script, an external method, and a page template.  The script is based
on a script
located in C:\Zope\Instance\2.9.7\Products\CMFPlone\migrations\v2 called
portlet_migration.py by DannyB (ender).

Script:

# Based on a script CMFPlone\migrations\v2\portlet_migration.py by DannyB
(ender).

from Acquisition import aq_base
import sys

def slotUpdate(self,portal):
    # traverse all folderish objects and remove all portlets in the right
and
    # left slots

    # handle current obj first
    processObject(aq_base(portal))
    processFolderish(portal)


def processFolderish(folder):
    for obj in folder.contentValues():
        unwrapped = aq_base(obj)
        # avoid max recursion depth error
        if unwrapped.isPrincipiaFolderish and \
          not unwrapped.meta_type == "CMF Collector":
            processObject(unwrapped)
            processFolderish(obj)

def processObject(obj):
    left = getattr(obj, 'left_slots', None)
    if left:
        new=renameEntries(left)
        obj.left_slots=tuple(new)
    right = getattr(obj, 'right_slots', None)
    if right:
        new=renameEntries(right)
        obj.right_slots=tuple(new)
def renameEntries(lines):
    new=[]
    return new


External Method:

Id: em_slot_update

Title: Slot Update
	
Module Name: slotUpdate
	
Function Name: slotUpdate

Page Template:

id:em_slot_update_pt





  
    Slot Update
  
  
    
          All Slots have been updated.
          
    
  





To use this:

Place the script on the file system at zope\instance\zope version\Extensions
I placed mine in C:\zope\instance\2.9.7\Extensions

Add the external method object to the Custom folder.
Add the Page Template to the Custom folder.

Test the page template by clicking on the test tab.  You should get a
message that all the slots have been cleared.  If you look at the
portal_migration.py script, 
you can see how this could be adapted for other usages.  I did not check the
properties of every folder, but all of those I checked had empty slots if
they previously had slots.
I hope some one will find this useful.


--
View this message in context: http://plone.293351.n2.nabble.com/migrating-portlets-from-2-5-to-3-tp1364193p6190760.html
Sent from the Product Developers mailing list archive at Nabble.com.



More information about the Product-Developers mailing list