[Grok-dev] Simple adapter question

Hugo Lopes hltbra at gmail.com
Thu Mar 5 13:31:39 EST 2009


> home = IHome(cave, fireplace)
IHome(cave, fireplace) means:
"return me some adapted object that provides ``IHome`` interface,
passing ``cave`` and ``fireplace`` to it"

IHome(cave, fireplace) is the same thing than use getAdapter passing
adaptees ``cave`` and ``fireplace`` and the interface ``IHome``.

>>> from zope import component
>>> home_by_zopecomponent = component.getMultiAdapter((cave, fireplace), IHome)
>>> home_by_shortcut = IHome(cave, fireplace)
>>> home_by_zopecomponent == home_by_shortcut
True

I hope it's some valid code, I didn't test it.

Read the zope.component README[1], it's very useful!

[1] - http://svn.zope.org/zope.component/trunk/src/zope/component/README.txt?rev=97420&view=markup


More information about the Grok-dev mailing list