[Zope3-checkins] CVS: Zope3/src/zope/app/component -
globalinterfaceservice.py:1.19
Jim Fulton
cvs-admin at zope.org
Fri Nov 21 12:11:26 EST 2003
Update of /cvs-repository/Zope3/src/zope/app/component
In directory cvs.zope.org:/tmp/cvs-serv31556/src/zope/app/component
Modified Files:
globalinterfaceservice.py
Log Message:
Changed to allow *both* interfaces and class declarations. (Not
positive that this is a good idea. :)
Also changed to use __name__ rather than getName.
=== Zope3/src/zope/app/component/globalinterfaceservice.py 1.18 => 1.19 ===
--- Zope3/src/zope/app/component/globalinterfaceservice.py:1.18 Tue Nov 4 22:08:21 2003
+++ Zope3/src/zope/app/component/globalinterfaceservice.py Fri Nov 21 12:11:25 2003
@@ -19,9 +19,10 @@
from zope.component.exceptions import ComponentLookupError
from zope.component import getService
from zope.app.interfaces.component import IGlobalInterfaceService
-from zope.interface import implements, providedBy
+from zope.interface import implements, providedBy, implementedBy
from zope.interface.interfaces import IInterface
from zope.component.utility import utilityService
+from types import ClassType
class InterfaceService:
implements(IGlobalInterfaceService)
@@ -71,11 +72,13 @@
yield id, interface
def _getAllDocs(self,interface):
- docs = [str(interface.getName()).lower(),
+ docs = [str(interface.__name__).lower(),
str(interface.__doc__).lower()]
- for name in interface:
- docs.append(str(interface.getDescriptionFor(name).__doc__).lower())
+ if IInterface.isImplementedBy(interface):
+ for name in interface:
+ docs.append(
+ str(interface.getDescriptionFor(name).__doc__).lower())
return '\n'.join(docs)
@@ -93,7 +96,12 @@
def provideInterface(self, id, interface):
if not id:
- id = "%s.%s" % (interface.__module__, interface.getName())
+ id = "%s.%s" % (interface.__module__, interface.__name__)
+
+ if not IInterface.isImplementedBy(interface):
+ if not isinstance(interface, (type, ClassType)):
+ raise TypeError(id, "is not an interface or class")
+ interface = implementedBy(interface)
self.__data[id]=(interface, self._getAllDocs(interface))
More information about the Zope3-Checkins
mailing list