On Wed, Sep 17, 2003 at 02:16:05PM -0400, Richard Shebora wrote:
Variable paths to create the folders... This is where I get confused about the syntax. The first two are created fine. I get a key error on the third level. Which means I am using the variables incorrectly. But how? ======================================================= folder1='folder01' folder2='folder02' folder3='folder03' folder4='folder04' folder5='folder05' container.manage_addProduct['PropertyFolder'].manage_addPropertyFolder(folder1, folder1,'')
Fine so far. As we go on, remember that container is bound to the folder that contains the script. It doesn't change (unless you were to explicitly bind something else to the name "container")
folder=container[folder1]
ok, folder now refers to container.folder01
folder.manage_addProduct['PropertyFolder'].manage_addPropertyFolder(folder2, folder2,'')
you have now created container.folder01.folder02...
folder=container[folder2]
container still means the container of the script. That's not where you put folder02! YOu're asking for container.folder02 and there is no such thing. You could instead get to the new folder this way: folder = container[folder1][folder2] ... but that's unnecessarily long; you've already got folder = container[folder1] so it's perfectly valid to use that like so: folder = folder[folder02] folder.manage_addProduct['PropertyFolder'].manage_addPropertyFolder(folder3, folder3,'') folder = folder[folder3] ... and so on. Once you have it working, your next assignment is to figure out how a single "for" loop would make this script a whole lot shorter and easier to maintain. :-) -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's SUPER FANG-HOLIC! (random hero from isometric.spaceninja.com)