[Zope] DTML parameter to Python script
Dylan Reinhardt
zope at dylanreinhardt.com
Fri Oct 3 10:44:14 EDT 2003
On Fri, 2003-10-03 at 03:23, Michael Bleijerveld wrote:
> Hi Dylan,
>
> When one of the links is pressed I need the name of the selected link
> (directoryname) for displaying the files in this directory.
>
> Example:
> - Documents
> - Pictures
> - Movies
>
> How can I use a Python script to set the current directory ?
Well... the easiest thing is to design so that you don't need to do
anything. For example, let's say you have the directory structure:
-----
app_dir/
list_contents
documents/
pictures/
movies/
-----
Where list_contents is a DTML Method like:
-----
<dtml-in "objectIds(object_type)" prefix=obj>
<dtml-var obj_item>
</dtml-in>
-----
Now, if you want list_contents to apply to a specific directory, you
need only cause the client to request a URL like:
app_dir/documents/list_contents
app_dir/pictures/list_contents
app_dir/movies/list_contents
It is not usually necessary to *set* the current directory if you let
Acquisition respond in the context of the client request.
If you need to use an object that regular Acquisition isn't going to
find correctly, you can use restrictedTraverse() or dtml-with.
HTH,
Dylan
More information about the Zope
mailing list