On Mon, Jul 03, 2000 at 10:38:27PM +0200, Dieter Maurer waxed eloquent:
> Charlie Wilkinson writes:
>  > 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>
>  > > 
>  > The bigger problem seems to be the namespace issue that Dieter was
>  > speaking of.
> I found a solution that is much easier than hacking the
> TreeDisplay code:
>   You do not plan to use REQUEST for information about the
>   request but only as a container for a temporary list.
>   This can be achieved without REQUEST
>       <dtml-with "_.namespace(r=[])">
>         <dtml-in "objectValues()" sort=id>
>           <dtml-if "_.has_key('add_to_menu')">
>              <dtml-call "r.append(_.getitem('sequence-item'))">
>           </dtml-if>
>         </dtml-in>
>         <dtml-return r>
>       </dtml-with>

Lots of good ideas, thanks guys!  However, I'm still getting an attribute
error on __getitem__.  I'm trying to figure out how namespaces get passed
around in Python to see if there's an easy way to fix this.

I've also found a workaround and pondered another:

- pass ['Folder','DTML Document'] to optionValues the normal way, i.e.:

<dtml-tree branches_expr="objectValues(['Folder','DTML Document'])"
    <IMG SRC="<dtml-var SCRIPT_NAME>/<dtml-var icon>">
  <dtml-if "meta_type == 'Folder'">
    <dtml-var title_or_id>
    <A HREF="<dtml-var tree-item-url>" TARGET="main"><dtml-var title_or_id></A>

...and then simply use DTML Documents and *only* DTML Documents for
stuff I want in the tree menu, primarily CGI forms, some of which might
be dynamically generated.  I guess if I smack into any limitations with
DMTL Documents, I'll have a Document call a method.  It's not ideal, but
it seems workable enough.

The other alternative might be to use ZCatalog with the Tree tag somehow.
I think it might do what I need, but I haven't given it much thought.

That said, I still think the idea you and Rik have been helping me
with is the most "elegant", but I've got a big site to build and very
little time.  Would it be any easier if instead of a DTML Method I used
an ExternalMethod as a wrapper/filter around objectValues?

It's very frustrating, as I keep thinking there's *got* to be an easy
way to fix this if I only had a half a Zope/Python clue.  I'm already
reading about as fast as I can!


            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/>
Failure is not an option. It's bundled with your software.

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

Reply via email to