hello, I have the following problem: I want to map a path from the filesystem to zope. For example: If I have the following path in the filesystem: "/home/wizards/spells/firespell" then I want zope, to create the folder hierarchy "/home/wizards/spell" and "firespell" should be a DTML-Document. I tried to do this with a external python-method. My thougt was, to create the folder "home", the change "self" to the new folder-Id and then, inside the new folder, create the folder "wizard" an so on. Here is the while loop, which should do the task: ("parts_of_path" is a list, with the elemtents (home, wizards, spell, firespell) according to the above example) while len(parts_of_path) > 1: if path_parts[0] in self.objectIds(['Folder']): self = path_parts[0] else: self = self.manage_addFolder(path_parts[0]) #set self to the new folder path_parts = path_parts[1:] The problem is, that, when the path is only "spell/firespell", then a folder "spell" is created, but when the path is longer, like above, then I get the following error-message: Error Type: AttributeError Error Value: 'None' object has no attribute 'objectIds' I think the problem is the "manage_addFolder" - function. It returns "None", instead of the folder-Id, which I need. Has anybody ever hat a similar problem?? I would be very happy, if anybody knows a solution to this. Thank you! Markus
Markus Jais wrote: [snippage]
("parts_of_path" is a list, with the elemtents (home, wizards, spell, firespell) according to the above example)
while len(parts_of_path) > 1: if path_parts[0] in self.objectIds(['Folder']): self = path_parts[0] else: self = self.manage_addFolder(path_parts[0]) #set self to the new folder path_parts = path_parts[1:]
[snipt]
I think the problem is the "manage_addFolder" - function. It returns "None", instead of the folder-Id, which I need.
You figured it out already, now take the next step :-) Actually, you do need some small adjustments... for part in parts_of_path[:-1]: if part not in self.objectIds(['Folder']): self.manage_addFolder(part) self = getattr(self, part) *warning*: untested code
participants (2)
-
Evan Simpson -
Markus Jais