I have the following file layout in my site (each of the following is a folder): Folder1 Folder2 Sub-folder1 Sub-folder2 scripts Within the folder scripts I have a python script (myAddFolder) with the following code: context.manage_addProduct['OFSP'].manage_addFolder(sub_id, sub_title) I am calling that script from a form. If I call it from a page within Sub-folder1, for example, the action would be scripts/myAddFolder. I would like it to then add a folder inside Sub-folder1. I understand why it will actually add it within the scripts folder, but I dont know how to get around this. I apologize if I could have found this somewhere else, but I didnt have any luck probably because I dont really know what I should have been searching for. Thank you in advance for your help.
Jeremiah White wrote at 2004-1-13 10:48 -0500:
... Within the folder �scripts� I have a python script (myAddFolder) with the following code: context.manage_addProduct['OFSP'].manage_addFolder(sub_id, sub_title) � I am calling that script from a form.� If I call it from a page within Sub-folder1, for example, the action would be �scripts/myAddFolder�.� I would like it to then add a folder inside Sub-folder1.� I understand why it will actually add it within the �scripts� folder, but I don�t know how to get around this.
The easiest way would be to give your "myAddFolder" an additional parameter "destination = None" and use as code: if destination is None: destination = context destination.manage_addProduct.... This way, you can explicitely determine the destination (by passing it as parameter). -- Dieter
Jeremiah White wrote:
I have the following file layout in my site (each of the following is a folder):
Folder1 Folder2 Sub-folder1 Sub-folder2 scripts
Within the folder "scripts" I have a python script (myAddFolder) with the following code: context.manage_addProduct['OFSP'].manage_addFolder(sub_id, sub_title)
I am calling that script from a form. If I call it from a page within Sub-folder1, for example, the action would be "scripts/myAddFolder". I would like it to then add a folder inside Sub-folder1. I understand why it will actually add it within the "scripts" folder, but I don't know how to get around this.
It's a question of acquisition. You formulate in this manner an acquisition path like:: /Folder/Sub1/scripts/myAddFolder Thus 'scripts' is the context for myAddFolder. You can formulate a path like:: /scripts/Folder/Sub1/myAddFolder where the most recent object is the one you want. Or you can put your script where it needs to be used. Acquisition encourages placement of objects not by types, but rather by function. --jcc
participants (3)
-
Dieter Maurer -
J Cameron Cooper -
Jeremiah White