[Zope] Newbie PARENTS question - <Folder instance at 8577a18>
Alexander Staubo
alex@mop.no
Thu, 30 Sep 1999 01:42:08 +0200
Be careful what you ask for. :) This may be what you want:
<dtml-var "PARENTS[1].id">
This should also answer your question about "a compound call". The
nesting qualifier in Python and Zope is the dot (".").
Note that Zope expressions are Python expressions. Some things are
attributes, others are functions. While
<dtml-var title_or_id>
gives you the title or ID of the document or associated object, this is
because Zope knows how to call functions. On the other hand,
<dtml-var "title_or_id">
will give the string representation of the title_or_id() function
(something like <function title_or_id at 8f5288>). Instead, use:
<dtml-var "title_or_id()">
This goes for a lot of things. Note that id is an attribute, not a
function. Doing "id()" ain't valid.
Also note that "dtml-var" only "renders" stuff. If you want to call
something with parameters, you need to use "dtml-call". For example:
<dtml-call "REQUEST.set('Foo', 1)">
But you can also do:
<dtml-call MyObject>
...assuming MyObject is callable; ie., it's either (a) a function, or
(b) a class instance implementing the Python __call__() method. Once you
read up on Python a bit (assuming you have not), you'll find these two
possibilities are the same side of different coins, really. :)
--
Alexander Staubo http://www.mop.no/~alex/
"`This must be Thursday,' said Arthur to himself, sinking low over
his beer, `I never could get the hang of Thursdays.'"
--Douglas Adams, _The Hitchhiker's Guide to the Galaxy_
> -----Original Message-----
> From: Chris Cooke-Johnson [mailto:chriscj@gocarib.com]
> Sent: 30. september 1999 01:03
> To: Phil Harris
> Cc: zope@zope.org
> Subject: [Zope] Newbie PARENTS question - <Folder instance at 8577a18>
>
>
> Thanx Phil,
>
> but that substitution is giving me "<Folder instance at 8577a18>" not
> the id of the parent folder...
>
> any ideas?
>
> Phil Harris wrote:
> >
> > Hi Chris
> >
> > Have you tried
> >
> > <dtml-var "PARENTS[1]">
> >
> > Might work ;¬)
> >
> > Phil
> > phil@philh.org
> >
> > -----Original Message-----
> > From: zope-admin@zope.org [mailto:zope-admin@zope.org]On
> Behalf Of Chris
> > Cooke-Johnson
> > Sent: 29 September 1999 22:27
> > To: zope@zope.org
> > Subject: [Zope] Newbie PARENTS question
> >
> > Hi there,
> >
> > I'm trying to reference the folder above from a DTML
> method. Basically
> > what I'm looking for is an equivalent to the the <!--#var
> id--> which
> > will give the id of the parent folder. In the DTML
> reference I found an
> > explanation of the PARENTS attribute with seems to be what
> I want but
> > I'm getting errors with both:
> >
> > <!--#var PARENTS[1]-->
> > and
> > <!--#expr PARENTS[1]-->
> >
> > How do I do this?
> >
> > Also, is it possible to nest calls? I.E. How can I make:
> >
> > <!--#var <!--#var id--><!--#var_another_method--> --> or similar
> >
> > In other words how can I make a compound call based on path
> (or other)
> > variables?
> >
> > Thanx in advance.
> >
> > Chris
> >
> > _______________________________________________
> > Zope maillist - Zope@zope.org
> > http://www.zope.org/mailman/listinfo/zope
> >
> > (Related lists - please, no cross posts or HTML encoding!
> >
> > To receive general Zope announcements, see:
> > http://www.zope.org/mailman/listinfo/zope-announce
> >
> > For developer-specific issues, zope-dev@zope.org -
> > http://www.zope.org/mailman/listinfo/zope-dev )
> >
> > _______________________________________________
> > Zope maillist - Zope@zope.org
> > http://www.zope.org/mailman/listinfo/zope
> >
> > (Related lists - please, no cross posts or HTML encoding!
> >
> > To receive general Zope announcements, see:
> > http://www.zope.org/mailman/listinfo/zope-announce
> >
> > For developer-specific issues, zope-dev@zope.org -
> > http://www.zope.org/mailman/listinfo/zope-dev )
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://www.zope.org/mailman/listinfo/zope
>
> (Related lists - please, no cross posts or HTML encoding!
>
> To receive general Zope announcements, see:
> http://www.zope.org/mailman/listinfo/zope-announce
>
> For developer-specific issues, zope-dev@zope.org -
> http://www.zope.org/mailman/listinfo/zope-dev )
>