Newbie Question - DTML syntax for referencing files with extensions
Hi all - I've been through the books and searched howtos, but can't find the trick. In short, I'm looking for the sytax to use to reference a file name that has an extension so that the extension is treated as a continuation of the filename and not treated as an attribute of a resulting non-existant object due to truncating the extension. I am also trying to manage acquisition selectively To put this is context, my goal is to create a list of links by looping through folders and their subfolders recursively. For each folder, if it has an icon to display, display it. If not list its title_or_id. Here is the non-functional code I would like to implement. dtml method: listuploads (found in the acquisition hierarchy) <dtml-in expr="uploadedpages.objectValues('Folder')" sort=id> # loop through subfolders of current context <dtml-with id only> # do not accidentally acquire the pageicon.gif of a parent folder <a href sequence-var-url> # make whatever is displayed a link to that folder's index_html <dtml-if expr="'pageicon.gif'"> # test the existance of a 'pageicon.gif' file in this folder <dtml-var pageicon.gif> # if found, display it <dtml-else> <dtml-var title_or_id> # if not found, display folder's title </dtml-if> <dtml-if expr="objectValues('Folder')"> # test if the current folder has subfolders <dtml-var listuploads> # if so, call this method recursively for the subfolders </dtml-if> </a> </dtml-with> </dtml-in> Questions - 1. Syntax for <dtml-if expr="pageicon.gif"> 2. How to acquire the listuploads method with a 'with only' in effect. Use another with pointing to its explicit URL? Use a path? like <dtml-var methodlibrary.listuploads> where methodlibrary is a folder object of the root? 3. Instead of the 'with only', is there a way to limit acquistion of pageicon.gif from the parent erroneously resulting in true in the if test? I'm sure this has been addressed before, but I could not find it. All suggestions appreciated ... Thanks, Gary
On Mon, Nov 11, 2002 at 12:12:54PM -0700, Gary Speer wrote:
Hi all - I've been through the books and searched howtos, but can't find the trick.
In short, I'm looking for the sytax to use to reference a file name that has an extension so that the extension is treated as a continuation of the filename and not treated as an attribute of a resulting non-existant object due to truncating the extension.
DTML is not good at this. You have to use a python expression and use dictionary syntax. So <dtml-var foo.html> would be more like <dtml-var expr="_['foo.html']"> I like it better in TAL: <span tal:content="here/foo.html"> </span> -- Paul Winkler http://www.slinkp.com "Welcome to Muppet Labs, where the future is made - today!"
Gary Speer writes:
I've been through the books and searched howtos, but can't find the trick.
In short, I'm looking for the sytax to use to reference a file name that has an extension so that the extension is treated as a continuation of the filename and not treated as an attribute of a resulting non-existant object due to truncating the extension.
Depending on how you want to use it: <dtml-var image.gif> <dtml-var "_.getitem('image.gif')"> <dtml-var "_['image.gif']"> <dtml-var "_.getattr(someObject,'image.gif')"> <dtml-var "someFolder['image.gif']">
I am also trying to manage acquisition selectively Search the mailing list archives for "aq_explicit" or "aq_base".
BTW, your code is very difficult to read. You might consider indentation to improve readability. You should read about the effect of "dtml-with" (e.g. in <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> ). Apparently, your current conception is not right. Dieter
Thank you Dieter - I have just about all of it working thanks to your suggestions and the references on your website! Still stuck on getting a dtml-if inside a dtml-with...only block to work inside a dtml-in loop without cancelling the sort order of the dtml loop and without acquiring. Other than this, the syntax is working fine. Thanks, Gary ----- Original Message ----- From: "Dieter Maurer" <dieter@handshake.de> To: "Gary Speer" <gspeer@cortech.org> Cc: <zope@zope.org> Sent: Tuesday, November 12, 2002 12:35 PM Subject: Re: [Zope] Newbie Question - DTML syntax for referencing files with extensions Gary Speer writes:
I've been through the books and searched howtos, but can't find the trick.
In short, I'm looking for the sytax to use to reference a file name that has an extension so that the extension is treated as a continuation of the filename and not treated as an attribute of a resulting non-existant object due to truncating the extension.
Depending on how you want to use it: <dtml-var image.gif> <dtml-var "_.getitem('image.gif')"> <dtml-var "_['image.gif']"> <dtml-var "_.getattr(someObject,'image.gif')"> <dtml-var "someFolder['image.gif']">
I am also trying to manage acquisition selectively Search the mailing list archives for "aq_explicit" or "aq_base".
BTW, your code is very difficult to read. You might consider indentation to improve readability. You should read about the effect of "dtml-with" (e.g. in <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> ). Apparently, your current conception is not right. Dieter
Gary Speer writes:
... Still stuck on getting a dtml-if inside a dtml-with...only block to work inside a dtml-in loop without cancelling the sort order of the dtml loop and without acquiring. What?
I like concise descriptions. But sometimes, conciseness can hurt... Dieter
participants (3)
-
Dieter Maurer -
Gary Speer -
Paul Winkler