On Wednesday 29 June 2005 04:17, 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 ... > > 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 ?
Well, we did not have a solid opinion on this yet. Certainly, the style guide says nothing about this. But I agree we should start looking up adapters all of the time, instead of checking for provided interfaces. I think this is something we should bring up on zope3-dev. Regards, Stephan -- Stephan Richter CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training _______________________________________________ Zope3-users mailing list [email protected] http://mail.zope.org/mailman/listinfo/zope3-users
