[Zope] context / addProduct question

J Cameron Cooper jccooper at jcameroncooper.com
Sat Jan 17 18:34:09 EST 2004


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




More information about the Zope mailing list