[Zope3-dev] RFC: preCreation view, postCreation view use cases

R. David Murray bitz@bitdance.com
Thu, 28 Mar 2002 15:14:45 -0500 (EST)


On Thu, 28 Mar 2002, Casey Duncan wrote:
> Hmm, then couldn't we create a utility that given a meta_type and
> container could return the appropriate adapter instance (or possibly
> just a decorator of the container)? I guess I need to look at the code...

Here's a half-thought-out alternative using PropertySets.  If you
create a PropertSetDef that holds the IFields needed to collect the
data required to create the object, you could register it on a
generic marker interface that object containers would support:

<properties
	name="MyComponent.CreationProperties"
	for="IObjectCreation"
	factory="Zope.App.OFS.ObjectManager.GenericCreationPropertySet+"
	def=".MyComponent.CreationPropertiesDef+" />

GenericCreationPropertySet might be a dummy adapter, and the creation
process would just use the data obtained from the form fields;
or perhaps it could store the data somewhere useful, where
the actual object factory could get at it.

Since PropertySets (will) have their own name space, we can now
specify a view:

<browser:view
	name="add"
	for=".MyComponent.ICreationProperties+"
	factory=".MyComponent.ObjectCreator+" />

where .MyComponent.ICreationProperties is a marker interface
supported by the CreationPropertiesDef PropertySetDef.

With these definitions (and a working PropertySets implementation!),
the adder function could then send us to:

.../theFolder/MyComponent.CreationProperties;properties/add;view

to get the add form.

Like I said, I haven't thought this through 100%, but my gut says
there should be a way to make it work.  I think you could even
use this to implement wizards, but I'm less sure of that.
Note that the name space issue is dealt with the same way most
of our name space issues are: by using the module path in the name.

"MyComponent.add" might make for a prettier URL, and by using
a default view you could then have:

.../theFolder/MyComponent.add;properties

As a bonus, the Formulator stuff would allow us to create a generic
add form.  And for simple objects, the PropertySetDef used for
object creation might be the same one used for the properties on
the object itself.  I'm visualizing being able to create a "property
holder" object by just creating a PropertySetDef for the properties
it holds, putting a couple directives in the product zcml file, and
having Z3 do the rest using default views.

Couple that with methods defined on the product class, and I think
you have something with all the rapid-prototyping advantages of
ZClasses, and none of the disadvantages.

--RDM