[Zope3-Users] Re: [Z3lab-checkins] r24502 - in
z3lab/cpsskins/trunk: . browser/editor browser/skin elements/formats
Florent Guillaume
fg at nuxeo.com
Wed Jun 29 04:17:28 EDT 2005
On 28 Jun 2005, at 23:39, svn at nuxeo.com wrote:
> Author: jmorliaguet
> Date: Tue Jun 28 23:39:48 2005
> New Revision: 24502
>
> Modified: z3lab/cpsskins/trunk/elements/formats/boxlayout.py
> ======================================================================
> ========
> --- z3lab/cpsskins/trunk/elements/formats/boxlayout.py (original)
> +++ z3lab/cpsskins/trunk/elements/formats/boxlayout.py Tue Jun
> 28 23:39:48 2005
> @@ -89,43 +89,54 @@
> else:
> self.markup = ''
>
> +################################################################
> +
> +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 ...
than testing directly for the provided interface, as it gives an
opportunity for an adapter to do its job. It's probably slower
though, and maybe not a pattern generally used for marker interfaces.
Opinions ?
Florent
--
Florent Guillaume, Nuxeo (Paris, France) CTO, Director of R&D
+33 1 40 33 71 59 http://nuxeo.com fg at nuxeo.com
More information about the Zope3-users
mailing list