How to put my scripts into a custom folder (Acquisition problems)
Hi, I am developing a simple Zope/Plone site and want to put custom scripts in a seperate folder, e.g. into /custom_scripts But how can I now calling these scripts without losing the correct context? If I e.g. want to call the script "/custom_scripts/myscript" from "/folder1" I have to write http://mysite/folder1/custom_scripts/myscript". The context of the script is then "/custom_scripts" which is bad as it loses the context of "folder1". When I put the python scripts into the root folder, everything works as the context of "http://mysite/folder1/myscript" is then "/folder1" which was my intention. I also don't completely understand it: Why is the context of the first example not "folder1/custom_scripts/"? Why does the context change to the container of the script? Is there any good solution to this? Or should I really put all my python scripts into the root folder? Best Regards, Hermann -- x1@aon.at GPG key ID: 299893C7 (on keyservers) FP: 0124 2584 8809 EF2A DBF9 4902 64B4 D16B 2998 93C7
On Sat, 2 Oct 2004 12:04:23 +0200, Hermann Himmelbauer <dusty@qwer.tk> wrote:
If I e.g. want to call the script "/custom_scripts/myscript" from "/folder1" I have to write http://mysite/folder1/custom_scripts/myscript". The context of the script is then "/custom_scripts" which is bad as it loses the context of "folder1".
You might want to use PATH_TRANSLATED or URL2 to acquire the path to the correct context and then restrictedTraverse it ... ... depending on what you want to achieve it might even make sense to do something like : http://mysite/folder1/custom_scripts/folder1/myscript which should probably fix the context to your taste, but then again I don't know what/how you're doing stuff in custom_scripts :) -- --- The Count
Hermann Himmelbauer wrote:
Hi, I am developing a simple Zope/Plone site and want to put custom scripts in a seperate folder, e.g. into /custom_scripts
But how can I now calling these scripts without losing the correct context?
If I e.g. want to call the script "/custom_scripts/myscript" from "/folder1" I have to write http://mysite/folder1/custom_scripts/myscript". The context of the script is then "/custom_scripts" which is bad as it loses the context of "folder1".
When I put the python scripts into the root folder, everything works as the context of "http://mysite/folder1/myscript" is then "/folder1" which was my intention.
I also don't completely understand it: Why is the context of the first example not "folder1/custom_scripts/"? Why does the context change to the container of the script?
Is there any good solution to this? Or should I really put all my python scripts into the root folder?
Best Regards, Hermann
I did the same and resolved by using context.aq_parent (or here/aq_parent) and it looks like it's working, but I'm just a zope newbie so I hope someone else will be so kind to confirm it's ok or explain why it's wrong... massimo
Hermann Himmelbauer wrote at 2004-10-2 12:04 +0200:
I am developing a simple Zope/Plone site and want to put custom scripts in a seperate folder, e.g. into /custom_scripts
Don't: is uses Zope in a less than optimal way. An alternative is to use CMFs "skins". -- Dieter
participants (4)
-
Dieter Maurer -
Hermann Himmelbauer -
massimo -
The Count