[Zope3-dev] defining interfaces

Stephan Richter stephan.richter@tufts.edu
Fri, 4 Apr 2003 21:06:30 -0500


On Friday 04 April 2003 20:04, Garrett Smith wrote:
> There appears to be several ways in which interfaces are defined in the
> Zope3 package. What is the recommended approach for people creating
> simple products and/or complex frameworks?

every product/package should have an interface package in it/

> - Create one file per interface, e.g. IFoo.py, located alongside the
> implementations?

Where is this still the case? This method of doing things was deprected when 
doing Namegeddon. 

> - Define interfaces in __init__.py?

Well, this has something to do with how imports are supposed to work; If you 
want "from zope.app.interfaces import IFoo" and "from 
zope.app.interfaces.blah import IBar" to work, you need to place IFoo in 
__init__.py of interfaces.

> - Create an "interfaces" directory where files of the same name contain
> respective interface definitions?

This should not be happening in the core either.

> When reading the Zope3 source files, is there anything to be inteferred
> by which of the above ways an interface is defined?

No, some usages are simply deprecated; note that the DevelCookbook and some 
other Wikis have not been updated since the grand renaming, so that they do 
not reflect working code. This is definitely one of the upcoming 
tasks...update the existing recipes.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training