[Zope3-dev] Re: Idea: Failure to lookup adapters
Philipp von Weitershausen
philipp at weitershausen.de
Wed Jan 17 16:57:14 EST 2007
Stephan Richter wrote:
> On Monday 15 January 2007 14:25, Sidnei da Silva wrote:
>> 'We've tried to look up an adapter for (ISomething, ITheOther) but
>> none was found'
>> 'Found an adapter for IFoo, which is a base class for the IBar
>> interface requested. No adapter has been found for the most-specific
>> interface IBar'
>>
>> Comments?
>
> My major concern is speed here.
It's a bit early to have that concern, we haven't even come up with a
strategy yet ;).
"Premature optimization is the root of all evil" -- Donald E. Knuth
> Any debug handling will make the registry
> slower; I am using adapters very heavily in my code and any slow-down of one
> lookup would be multiplied many times.
There are certainly ways in Python to have debug code in an application
that won't be run in production mode, e.g.:
if __debug__:
# do expensive logging call here, or whatever
Code like this won't be run with python -O (which is what you'd
obviously use in production).
> I wonder whether a different approach could be taken. The APIDOC code does
> already a registration analysis. Maybe we can use the registrations in a away
> that they simulate the adapter registry. Thus you could provide APIDOC (via
> the Web UI or Python) with a component or instance and it tells you how it
> tries to look up the adapter. Clearly that would be much slower, but okay for
> inspection.
Sounds good. I like the explainAdapter() suggestion.
--
http://worldcookery.com -- Professional Zope documentation and training
2nd edition of Web Component Development with Zope 3 is now shipping!
More information about the Zope3-dev
mailing list