[Zope3-dev] factoryFromClass: for_container

Jim Fulton jim@zope.com
Mon, 15 Apr 2002 14:34:14 -0400


Gary Poster wrote:
> 
> The zcml for adding content factories should add a for_container so that a
> fully equipped tag might look something like this (only the first three
> attributes would be required):
> 
>     <zmi:factoryFromClass
>         name="Job"
>         class=.Job+"
>         permission_id="Zope.Public"
> 
>         title="Job" # optional (use name if absent)
>         description="A job to be used in the JobBoard" # optional
>         for_container=".IJobBoard+" # optional (default: IContainer)
>         creation_markers=".IJob.IJobCreateMarker" # optional
>             # (default: ZMI.IGenericCreateMarker)
>     />
> 
> (notice also I'm proposing a change from "marker_interface" to
> "creation_marlers" for the pre-create view stuff)

Can we get this turned into a proposal at:

http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/Zope3Proposals

???

Could you explain what a "creation marker" is? I don't follow this.

> If for_container is not specified, IContainer is assumed.
> 
> This would allow addables to be cleanly associated with a container interface,
> so that things like the JobBoard example, for instance, would easily have only
> the one appropriate addable available to them; and so that addables like Job
> would not appear in the standard addables list for a basic container.

I'm not sure that Job Boards would want to use this at all. Some containers
don't need or want to be as flexible as folders.
 
> I think this should also be used for the services "factoryFromClass"--this
> would allow ObjectHub plugins (or any other service plugins) to use the
> addable/factory system, for instance. The default for_container value for the
> service version would be IServiceManager, or ILocalServiceManager, using my
> naming system from a previous email.

I agree that there's some generalization lurking here. I'd like to understand
your generalization better.

BTW, another way to approach this is to have containers say which kinds of
things they are willing to contain, by specifying an interface that their items
must support. Maybe this is related to what you are proposing.
 
> It would also make sense to go ahead and implement the creation_markers
> system for service factories and addables as well, I think.  That will be
> virtually a non-task.
> 
> If I haven't heard any negatives or alternate suggestions on this in a couple
> of days then I'll proceed, both in adding for_container and in renaming
> creator_markers.

I think we need more than a couple days of silence before making a change 
this extensive.

In any case, please make this a proposal so we have a more permanent record of the discussion.

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