[Zope3-dev] IFactory, and composite factories
Jim Fulton
jim@zope.com
Sat, 31 Aug 2002 09:20:29 -0400
R. David Murray wrote:
> I just closed collector issue 9, document composite factories.
> However, I have a question.
>
> A composite factory looks like:
> c(b(a(context)))
This is when you have:
factory="a b c"
> For a ViewFactory and an adapter I think I know what context is.
Note that even for a view, all but the last factory in list
must be adapters (e.g. "a" and "b" in the example).
> But for other things (securityPolicy, utility) I'm not quite sure
> what it is.
I'm not aware that composite factories can be used for anything but
adapters and views.
> Is "context" a good generic name to use to document
> this?
> I'm expecting that it is, but: IFactory.py says that '__call__'
> takes no arguments. How can that be if the above is the correct
> form for a composite factory?
IFactory is for creating "content".
The factory attribute in ZCML is for creating other kinds of components.
Adapter factories take a single argument. Resource factories take a
single argument (the request). View factories take two arguments, context,
and request. Utility and service factories take no arguments.
> Should IFactory take 'context' as a
> __call__ argument?
No.
> But you wouldn't have a context for a placeless
> factory.
You wouldn't have one for a placeful factory either.
> Are there in fact two Factory interfaces, one that takes
> no arguments and say IChainedFactory that takes an object instance?
We really don't bother with interfaces for the factories names
in the ZCML factory attributes, because these factories are not
components.
> Or
> am I confused and these other directives can't have chained factories?
AFAIK, only adapters and views have chained factories. Also,
AFAIK, nobody is using this feature anymore.
> Or am I just confused because I haven't read enough zope3 code <grin>?
You are confused because the terminology is a little confusing.
"Factory" is a pretty general term that we are using for two different
things.
Jim
--
Jim Fulton mailto:jim@zope.com Python Powered!
CTO (888) 344-4332 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org