[Zope3-dev] Re: capi vs zapi

Philipp von Weitershausen philipp at weitershausen.de
Sun Mar 6 09:07:20 EST 2005


Stephan Richter wrote:
> On Saturday 05 March 2005 10:12, Philipp von Weitershausen wrote:
> 
>>>capi is a short form for zope.component and should only be used when zapi
>>>cannot be used. For example, you cannot use zapi in zope.app.traversing,
>>>because this package is part of zapi. Another use case is when you
>>>develop a package that does not depend on zope.app, then you must use the
>>>component API directly.
>>
>>Of course, you're totally right on when to zope.component and not zapi.
>>However, I think calling it 'capi' dilludes new developers (and even
>>Garret here) into believing we're dealing with some sort of different
>>API, while in fact it's just zope.component. As I've said in a post to
>>Garret's checkin msg just a minute ago, we should replace 'capi' with
>>'zope.component' for clarity at least in doctests...
> 
> 
> Jim thinks so too, I disagree. I think it is a great symmetry in the code and 
> wherever I use it in tests I do the import in the test, i.e.
> 
>   >>> import zope.component as capi

The difference is that zapi exists as a package in zope.app.zapi, 
meaning that name really exists. This capi name you're using doesn't 
exist. You're just making an alias that just saves you a handful 
characters of typing but creates a lot more confusion. If Garret and I 
made the mistake, other people will too.

Explicit is better than implicit.

Philipp


More information about the Zope3-dev mailing list