On Mon, Jul 03, 2000 at 09:35:06AM +0200, Rik Hoekstra waxed eloquent:
> 
> Charlie Wilkinson writes:
[...] 
> I'm trying to use dtml-tree to create a selective menu of objects based
> on whether or not the object has an "add_to_menu" property.
[...]
> [rh]
> Try (yes, this is tested):
> <dtml-call "REQUEST.set('ret', '')">
>  <dtml-in "objectValues()" sort=id>
>      <dtml-if "_.has_key('add_to_menu')">
>        <dtml-call "ret.append(id)"> 
>      </dtml-if>
>  </dtml-in>
> <dtml-return ret>
> 
> Two notes:
> - the string approach is an unnecessary hack. I changed it to standard
> Python list idiom

It sure looks a lot cleaner, thanks Rik.

> - if you append sequence-item it will include your whole method, which
> presumably is not what you want in your tree. Use id.

Not sure.  Supposedly objectValues() returns "actual objects", and
I assumed that using sequence-item would be something closer to that.
<shrug>  The finer points of python are still lost on me, but I'm working
on it.

The bigger problem seems to be the namespace issue that Dieter was
speaking of.  When I tried your code, I got Attribute errors on
__getitem__.  It appears that Tree does not inherit the usual DMTL
namespace.  I've been looking at Tree trying to figure out how to add
it back in or somehow sneak my namespace into it, wondering what I'll
break in the process.  (But that's what makes Zope so interesting! 8-)

-cw-

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            Charlie Wilkinson - [EMAIL PROTECTED] - N3HAZ
Parental Unit, UNIX Admin, Homebrewer, Cat Lover, Spam Fighter, HAM, SWLer...
    Visit the Radio For Peace International Website: http://www.rfpi.org/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            CLOBBER INTERNET SPAM:  See!! <http://spam.abuse.net/>        
                                   Join!! <http://www.cauce.org/>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
QOTD:
Failure is not an option. It's bundled with your software.

_______________________________________________
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to