[Zope-CMF] Files to Portal Files conversion script

David Chandek-Stark dc at duke.edu
Tue Oct 21 14:00:32 EDT 2003


Looking for comments on this script, which takes all objects in its 
folder (Portal Folder) of type 'File', and create analagous objects in a 
'temp' subfolder of type 'Portal File'. It appears to work, but the 
manage_upload() call, especially, feels like a hack. P.S. I'm a relative 
Python newbie. Thanks--David.

###
request = container.REQUEST
response = request.RESPONSE
mainfolder = container
temp = 'temp'
mainfolder.manage_addPortalFolder( temp )
tempfolder = getattr( mainfolder, temp )
files = mainfolder.objectValues( 'File' )

for f in files:
     p_disp = tempfolder.manage_addProduct[ 'CMFDefault' ]
     p_disp.manage_addContent( f.id(), 'Portal File' )
     newfile = getattr( tempfolder, f.id() )
     newfile.manage_edit( title=f.title, precondition=f.precondition, 
content_type=f.content_type )
     newfile.manage_upload( f.index_html( request, response ) )
###

-- 
David Chandek-Stark
dc at duke.edu




More information about the Zope-CMF mailing list