On Sun, Apr 12, 2009 at 10:31 AM, <gl...@divmod.com> wrote: > > On 11 Apr, 08:41 pm, est...@sindominio.net wrote: >> >> factory = IFooFactory(myService) >> factory.bar = "some value" >> >> it works, but I'd rather use this: >> >> factory = IFooFactory(myService, configurationObject) > > This is a long and terrible road you're about to start down. It's hard for > me to explain exactly why it's so painful, but trust me, it is. > > What you're doing now, passing out-of-band arguments to the IFooFactory > adapter, whose concrete type you are *not supposed to know* at that point in > the control flow, is bad. But trying to force adaptation to become > full-fledged multimethods is worse. If you want multimethods, I believe > PEAK provides a package that implements them. >
Also, Zope has getMultiAdapter(). The canonical example is adapting a model object and a request object to a view object. I don't think it's as bad as glyph says. I probably wouldn't use it in the case you describe -- calling methods on objects is almost always better. jml _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python