Martin Aspeli wrote: > >> 3) Define an adapter from the IMyFolder interface to a new interface, say >> IHasMyItems, which has a method called "myitems". The MyPortlet then >> calls >> aq_chain and traverses the acquisition chain by hand until it has found >> an >> object which can be adaptet to a IHasMyItems. > > I'd do something similar to this, but the adapter sounds superfluous. > > In the renderer, I'd do: > > folder = None > for parent in aq_chain(aq_inner(self.context)): > if IMyFolder.providedBy(parent): > folder = parent > break > > if folder is not None: > ... > > You already have an interface describing the type of object you're > looking for, so I'd just use that. > > Martin >
Thanks for the prompt reply, which has helped me a lot, Martin. So method 3). I agree that writing an adapter may be superfluous. However, assume that I have to process the list of IMyItems of IMyFolder before I display them in the MyPortlet. Assume as well that MyPortlet is not the only piece of code where the result of this processing is used. In this case, I guess that a method that does this processing fits best in an adapter like IHasMyItems (as this allows my to extend the content folder IMyFolder with functionality without deriving a custom class). Or would you propose to use a global function instead? Best, Marc -- View this message in context: http://plone.293351.n2.nabble.com/What-s-the-proper-way-to-add-methods-to-dexterity-types-tp4992210p4992630.html Sent from the Product Developers mailing list archive at Nabble.com. _______________________________________________ Product-Developers mailing list [email protected] http://lists.plone.org/mailman/listinfo/product-developers
