I've trying to write a little dtml method that will out put a list of images in a given location using a variable "path" with is passed from a form. ?path=photos1... but haven't had much luck because it doesn't seems to interpret the variable i want to be a path. if i put the path directly into the program ie "photos1.objectValues()" it works. but i need it to be feed from a variable path. <dtml-in expr="path.objectValues('CMF ZPhotoSlides')"> <folder path="wombat/&dtml-id;/" name="&dtml-title_or_id;" amount="<dtml-in expr="objectValues(['CMF ZPhoto'])"><dtml-if sequence-end><dtml-var count-description></dtml-if></dtml-in>"/> </dtml-in> this should simple ;-) but i'm missing something. thanks... holden
holden, I don't know how to do this in dtml but in zpt I can create variables so rather than doing path="wombat/&dtml-id;/" I would in zpt anyway do a tal:define="mypath python:'wombat/'+getID()+'/'" and then have <folder path="" tal:attribute="path mypath" Can you do something similar in dtml?? ____________________________________________ Peter Millar -----Original Message----- From: zope-bounces+peter.millar=parasyn.com.au@zope.org [mailto:zope-bounces+peter.millar=parasyn.com.au@zope.org] On Behalf Of Wombie Tomek Sent: Thursday, 20 January 2005 13:00 To: zope@zope.org Subject: [Zope] question on objectValues I've trying to write a little dtml method that will out put a list of images in a given location using a variable "path" with is passed from a form. ?path=photos1... but haven't had much luck because it doesn't seems to interpret the variable i want to be a path. if i put the path directly into the program ie "photos1.objectValues()" it works. but i need it to be feed from a variable path. <dtml-in expr="path.objectValues('CMF ZPhotoSlides')"> <folder path="wombat/&dtml-id;/" name="&dtml-title_or_id;" amount="<dtml-in expr="objectValues(['CMF ZPhoto'])"><dtml-if sequence-end><dtml-var count-description></dtml-if></dtml-in>"/> </dtml-in> this should simple ;-) but i'm missing something. thanks... holden _______________________________________________ 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 )
Peter Millar wrote:
holden,
I don't know how to do this in dtml but in zpt I can create variables so rather than doing path="wombat/&dtml-id;/" I would in zpt anyway do a tal:define="mypath python:'wombat/'+getID()+'/'" and then have <folder path="" tal:attribute="path mypath"
what's wrong with just: <folder tal:attributes="path string:wombat/${getId}/" ? cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Wombie Tomek wrote:
I've trying to write a little dtml method that will out put a list of images in a given location using a variable "path" with is passed from a form. ?path=photos1...
but haven't had much luck because it doesn't seems to interpret the variable i want to be a path. if i put the path directly into the program ie "photos1.objectValues()" it works. but i need it to be feed from a variable path.
<dtml-in expr="path.objectValues('CMF ZPhotoSlides')">
<folder path="wombat/&dtml-id;/" name="&dtml-title_or_id;" amount="<dtml-in expr="objectValues(['CMF ZPhoto'])"><dtml-if sequence-end><dtml-var count-description></dtml-if></dtml-in>"/>
</dtml-in>
this should simple ;-) but i'm missing something.
<dtml-in "_[path].objectValues()"> You want to look up an object in the namespace, and to do so you must use dictionary lookup on the namespace (which is the variable "_".) One could also use getattr or similar. Think of it this way:
namespace = {"photos1":someobject, "photos2":someotherobject} path = "photos1" ph = namespace[path] # being the same as... ph = namespace["photos1"] # which is like saying <dtml-var "photos1.objectValues()">
--jcc
holden, take a look at the functions restrictedTraverse(path) and perhaps unrestrictedTraverse(path). These may not be the most appropriate functions to use, but they will return an object reference using a path (such as "folder/subfolder/page"). In your example it could look something like the following: <dtml-in expr="restrictedTraverse(path).objectValues('CMF ZPhotoSlides')"> This is, of course, relative to the folder/object you are currently "in". If anyone has a more appropriate solution, I'd be interested in hearing about it, too! Garth
participants (5)
-
Chris Withers -
Garth B. -
J Cameron Cooper -
Peter Millar -
Wombie Tomek