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

_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to