Re: [Zope] DTML parameter to Python script
On Thu, 2003-10-02 at 12:03, Michael Bleijerveld wrote: <snip>
url=context.REQUEST.URL1 + '/' + 'test' return url
Here's the problem. Even though this code is called several times in one request, the URL1 property of REQUEST isn't going to change at any point during the request. That explains why every time through your loop, you're getting the same result. It's not clear what you *mean* to have happen in this script... the only line that seems to do anything is this one:
container.REQUEST.set('CurrentDir',directory)
Which only re-names the "directory" variable, which I assume was a parameter to the script. It's not clear what purpose this could serve. Perhaps you meant for the generated URL to have something to do with the current user and the directory name passed in. That might be: url = '/'.join([context.REQUEST.URL1,username,directory]) Or something like that. If that doesn't help, maybe you could describe what the script is *supposed* to return. HTH, Dylan
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 ? Regards. Michael ----- Original Message ----- From: "Dylan Reinhardt" <zope@dylanreinhardt.com> To: "Zope Users" <zope@zope.org> Sent: Thursday, October 02, 2003 11:15 PM Subject: Re: [Zope] DTML parameter to Python script
On Thu, 2003-10-02 at 12:03, Michael Bleijerveld wrote: <snip>
url=context.REQUEST.URL1 + '/' + 'test' return url
Here's the problem.
Even though this code is called several times in one request, the URL1 property of REQUEST isn't going to change at any point during the request. That explains why every time through your loop, you're getting the same result.
It's not clear what you *mean* to have happen in this script... the only line that seems to do anything is this one:
container.REQUEST.set('CurrentDir',directory)
Which only re-names the "directory" variable, which I assume was a parameter to the script. It's not clear what purpose this could serve.
Perhaps you meant for the generated URL to have something to do with the current user and the directory name passed in. That might be:
url = '/'.join([context.REQUEST.URL1,username,directory])
Or something like that. If that doesn't help, maybe you could describe what the script is *supposed* to return.
HTH,
Dylan
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
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
participants (2)
-
Dylan Reinhardt -
Michael Bleijerveld