[Zope] question on objectValues
J Cameron Cooper
zope-l at jcameroncooper.com
Wed Jan 19 22:30:15 EST 2005
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
More information about the Zope
mailing list