Factory APIs¶
There are APIs for creating objects and discovering factories.
-
zope.component.
createObject
(__factory_name, *args, **kwargs)[source]¶ Create an object using a factory
Finds the named factory in the current site and calls it with the given arguments. If a matching factory cannot be found raises
ComponentLookupError
. Returns the created object.A context keyword argument can be provided to cause the factory to be looked up in a location other than the current site. (Of course, this means that it is impossible to pass a keyword argument named “context” to the factory.
See also
Function
createObject
for notes, andIComponentArchitecture
for the defining interface.
-
zope.component.
getFactoryInterfaces
(name, context=None)[source]¶ Get interfaces implemented by a factory
Finds the factory of the given name that is nearest to the context, and returns the interface or interface tuple that object instances created by the named factory will implement.
See also
Function
getFactoryInterfaces
for notes, andIComponentArchitecture
for the defining interface.
-
zope.component.
getFactoriesFor
(interface, context=None)[source]¶ Return a tuple (name, factory) of registered factories that create objects which implement the given interface.
See also
Function
getFactoriesFor
for notes, andIComponentArchitecture
for the defining interface.