[Zope-Checkins] CVS: Zope3/lib/python/Zope/ComponentArchitecture - component-meta.zcml:1.1.2.2 hooks.py:1.1.2.16 metaConfigure.py:1.1.2.18
Jim Fulton
jim@zope.com
Mon, 4 Mar 2002 13:54:27 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/ComponentArchitecture
In directory cvs.zope.org:/tmp/cvs-serv20274
Modified Files:
Tag: Zope-3x-branch
component-meta.zcml hooks.py metaConfigure.py
Log Message:
Added factory directive.
Fixed bug in provideFactory that caused instances that implemented
IFactory independent of the class to be rejected.
=== Zope3/lib/python/Zope/ComponentArchitecture/component-meta.zcml 1.1.2.1 => 1.1.2.2 ===
<directive name="utility" attributes="component, provides"
handler="Zope.ComponentArchitecture.metaConfigure.utility" />
+ <directive name="factory" attributes="component, factory_id"
+ handler="Zope.ComponentArchitecture.metaConfigure.factory" />
<directive name="view" attributes="component, type, name, for, layer"
handler="Zope.ComponentArchitecture.metaConfigure.view" />
<directive name="defaultView"
=== Zope3/lib/python/Zope/ComponentArchitecture/hooks.py 1.1.2.15 => 1.1.2.16 ===
def provideFactory_hook(qname, factory):
- _verify(_IFactory, factory.__class__)
+ _verify(_IFactory, factory)
_factories[qname] = factory
def createObject_hook(place, name):
=== Zope3/lib/python/Zope/ComponentArchitecture/metaConfigure.py 1.1.2.17 => 1.1.2.18 ===
# FOR A PARTICULAR PURPOSE.
-from hooks import provideAdapter, provideUtility
+from hooks import provideAdapter, provideUtility, provideFactory
from ViewService import provideView, setDefaultViewName
from ResourceService import provideResource
from SkinService import defineSkin
@@ -34,6 +34,20 @@
discriminator = ('utility', provides),
callable = provideUtility,
args = (provides, component),
+ )
+ ]
+
+def factory(component, factory_id=None):
+ if factory_id is None:
+ factory_id = component
+
+ component = resolve(component)
+
+ return [
+ Action(
+ discriminator = ('factory', factory_id),
+ callable = provideFactory,
+ args = (factory_id, component),
)
]