[z3-five] Menu and MenuItem in Five

Maciej Wisniowski maciej.wisniowski at coig.katowice.pl
Fri Oct 20 08:55:40 CEST 2006


> and my page template nope.pt:
> -------------------------
> <p metal:use-macro="here/generic/macros/genericHeader">Generic Header</p>
> print nopeee
> <p metal:use-macro="here/generic/macros/genericFooter">Generic Footer</p>
> -------------------------
>   
I forgot to say that I have 'generic' attribute which is a ZPT
with few simple macros. If somebody is interested I may
post it's definition. AFAIR it was taken from another Zope
product like Boring or something like that.

> Did I miss something here??
Today I found that I missed two things:
1.  Ocassionaly I got AttributeError:
'zope.thread.local' object has no attribute 'interaction'.
Seems to be same thing as this one:
http://www.zope.org/Collectors/Zope/2190
so I added:

from Products.Five import security
security.newInteraction()

2. tabs from Five were not correctly highlighted

It was necessary to change @@ to %40 in 'action'
d['action'] = d['action'].replace('@', '%40')

Finally it looks like:

    def filtered_manage_options(self, REQUEST=None):
        """test...
        """
        options = SimpleItem.filtered_manage_options(self, REQUEST)
       
        security.newInteraction()
        # it is Zope2.8 so we have to use getView instead of getMultiAdapter
        view = zapi.getView(self, 'view_get_menu' ,self.REQUEST)
        view = view.__of__(self)
        five_options = view['zmi_views']

        for d in five_options:
            #change title to label
            d['label'] = d.get('title', '')
            d['action'] = d['action'].replace('@', '%40')

            options.append(d)
        return options


I wonder whether all of this is necessary if I
still can use simple 'old way' of defining management
tabs. But till now I was not able to realize what for
this 'menu' stuff from zcml may be used for in Z2 :)

-- 
Maciej Wisniowski


More information about the z3-five mailing list