[Zope-dev] Recursive folders from Python

Dieter Maurer dieter@handshake.de
Mon, 30 Oct 2000 19:43:11 +0100 (CET)


Jason Spisak writes:
 > Does anyonw know why this code won't create a folder within a folder. 
 > It's tells me the id is already in use, so that means it's not
 > descending into the newly created folder to make another folder.
 > 
 > def create(self):
 >     for digit in range(0, 10):
 >         folder    = self.manage_addFolder(str(digit), str(digit))
 >         subfolder = self.folder.manage_addFolder(str(digit), str(digit))
Apparently, the above line should add a new folder in (say) '00'.
What it does, however, is trying to add the new folder in the object named
'folder' (accessible from 'self'). This may well go wrong.

Keep in mind, that the local name space of the function 'create'
(where your variable 'folder' lives) is disjunct from the attribute
namespace of 'self' (where the attribute 'folder' lives).


Dieter