[Zope3-Users] Re: [Z3lab-checkins] r24502 - in z3lab/cpsskins/trunk: . browser/editor browser/skin elements/formats

Jean-Marc Orliaguet jmo at ita.chalmers.se
Fri Jul 1 10:04:48 EDT 2005


Jim Fulton wrote:

> Florent Guillaume wrote:
> ...
>
>>> +################################################################
>>> +
>>> +def renderItems(content, start='', repeat='%s', separator='', 
>>> end='', **kw):
>>> +    if IMenuItems.providedBy(content):
>>> +        items_markup = [start]
>>> +        items_append = items_markup.append
>>> +        for item in content:
>>> +            items_append(repeat % (item['url'], item['title']))
>>> +            items_append(separator)
>>> +        items_append(end)
>>> +        return ''.join(items_markup)
>>> +    else:
>>> +        return ''
>>
>>
>>
>> In general in Zope 3 it's my understanding that it's better to do
>>
>> try:
>>     c = IMenuItems(content)
>> except ComponentLookupError:
>>     return ''
>> ... c used as iterable ...
>> return ...
>
>
>
> Note that I prefer:
>
>    c = IMenuItems(content, None)
>    if c is None:
>       return ''
>
>    ...
>


here is a trival question but what is the syntax for multi-adapters?

        layout_renderer = getMultiAdapter((layout, request),  IRenderer)

works, but:

         layout_renderer = IRenderer(layout, request)

returns a BrowserRequest object instead of the renderer implementing
IRenderer

and:

         layout_renderer = IRenderer((layout, request))

returns a TypeError saying 'Could not adapt'


/JM



More information about the Zope3-users mailing list