[Zope3-checkins] CVS: Zope3/src/zope/component - factory.py:1.7
interfaces.py:1.21
Stephan Richter
srichter at cosmos.phy.tufts.edu
Tue Mar 2 09:26:16 EST 2004
Update of /cvs-repository/Zope3/src/zope/component
In directory cvs.zope.org:/tmp/cvs-serv22385/src/zope/component
Modified Files:
factory.py interfaces.py
Log Message:
Update factory __call__ API.
Then, I also think that verifyObject does not behave right, when the interface
says __call__(self, *args, **kw). In this case __call__(self, arg1) should
validate true, since it fulfills the previous pattern; i.e. we need some
flexibility in verifyObject() for cases in which the signiture is not always
the same. This was particularly important for factories.
I deactivated verifyObject() for this reason and replaced it by the weaker
isImplementedBy().
=== Zope3/src/zope/component/factory.py 1.6 => 1.7 ===
--- Zope3/src/zope/component/factory.py:1.6 Thu Jan 8 15:48:22 2004
+++ Zope3/src/zope/component/factory.py Tue Mar 2 09:26:16 2004
@@ -11,10 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""factory service
-"""
-
+"""Global Factory Service
+$Id$
+"""
from zope.interface.verify import verifyObject
from zope.interface import implements
from zope.component.interfaces import IFactory
@@ -48,7 +48,11 @@
def provideFactory(self, name, factory, info=None):
"""See IGlobalFactoryService interface"""
- verifyObject(IFactory, factory)
+ # XXX At this point the verify object code does not support variable
+ # arguments well. For example, I was not able to register any factory
+ # that requires constructor arguments! (SR)
+ # verifyObject(IFactory, factory)
+ assert IFactory.isImplementedBy(factory)
self.__factories[name] = factory
if info is not None:
self.__info[name] = info
@@ -87,7 +91,7 @@
def queryFactoriesFor(self, iface, default=None):
"""See IFactoryService interface"""
return [(n, f) for n, f in self.__factories.items() \
- if iface in f.getInterfaces()] or default
+ if iface in tuple(f.getInterfaces())] or default
def getFactoryInfo(self, name):
return self.__info.get(name)
@@ -98,9 +102,7 @@
factoryService = GlobalFactoryService()
provideFactory = factoryService.provideFactory
-
-
-_clear = factoryService._clear
+_clear = factoryService._clear
# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
from zope.testing.cleanup import addCleanUp
=== Zope3/src/zope/component/interfaces.py 1.20 => 1.21 ===
--- Zope3/src/zope/component/interfaces.py:1.20 Fri Feb 20 15:35:33 2004
+++ Zope3/src/zope/component/interfaces.py Tue Mar 2 09:26:16 2004
@@ -284,7 +284,7 @@
# This functionality is needed for making advanced factories that
# do what other factories do, and then mark the resultant object
# with an interface.
- def __call__():
+ def __call__(*args, **kw):
"""Return an instance of the objects we're a factory for."""
More information about the Zope3-Checkins
mailing list