[Zope] Re: [Zope-CMF] copy/paste Folders

George Stroussopoulos strusos@yahoo.com
Thu, 13 Jun 2002 16:12:47 +0100 (BST)


I have this Folder Structure
CPM
 |-ALLCHANNELS
 |-PORTALFOLDER
 |-REFPORTALFOLDER

I am trying to copy all the channels contained in the
portals and refportals folders and their subfolder
into the allchannels folder.
The code for the copy/paste is almost identical for
both the folders.I call from portalfolder a function
called exportChannels and the same from the
refportalfolder.

#CODE:

destination=getattr(self,self.theConfigurationManager.getTheAllChannelsFolder().id
)
portalslist = self.getPortals()
		for pl in portalslist:
			plchannelslistids =[]
			print  pl.id
			
			plchannelslistids = pl.getChannelIds()
			for c in plchannelslistids:
				print c
			
			if len(plchannelslistids): 
			
destination.manage_pasteObjects(pl.manage_copyObjects(plchannelslistids))
		
			else:
				print  "Empty Channels List"
			plChannelFoldersList=[]
			plChannelFoldersList = pl.getChannelFolders()
			for plc in plChannelFoldersList:
				plchannelslistids=[]
				plchannelslistids = plc.getChannelIds()
				print plc.id
				
				if len(plChannelFoldersList): 
				
destination.manage_pasteObjects(plc.manage_copyObjects(plchannelslistids))
		
				else:
					print  "Empty Channel Folder List"

####
It fails inside the copysupport.py
in the manage_pasteObjects at line 168
      id=self._get_id(ob.getId())
because the previous line 167
      ob=ob._getCopy(self)
returns none as ob

    def _getCopy(self, container):
        # Ask an object for a new copy of itself.
        f=tempfile.TemporaryFile()
        self._p_jar.exportFile(self._p_oid,f)
        f.seek(0)
        ob=container._p_jar.importFile(f)
        f.close()
        return ob

It throws this error because of the above error.
2002-06-12T15:00:48 PROBLEM(100)
Products.CollaboratingPortals.RefPortalFolder 1
Traceback (innermost last):
  File
/home/toolkit/Zope251_bck/lib/python/Products/CollaboratingPortals/RefPortalFolder.py,
line 450, in ExportAllChannels
    (Object: RefPortals)
  File
/home/toolkit/Zope251_bck/lib/python/OFS/CopySupport.py,
line 168, in manage_pasteObjects
    (Object: AllChannels)
AttributeError: 'None' object has no attribute 'getId'


######
I have tried it with each folder containing only one
channel and still fails.
Their must be something i don't see.
Any suggestions?

Thanks in advance.



____________________________________________________________
Do You Yahoo!?
Αποκτήστε τη δωρεάν @yahoo.gr διεύθυνση σας στο http://www.otenet.gr