[Zope-CMF] FactoryTypeInformation

Tres Seaver tseaver@digicool.com
Tue, 01 May 2001 22:03:46 -0400


marc lindahl wrote:
> 
> Is it just me, or will FactoryTypeInformation only work with
> products that require only an ID to be Added?
> 
> e.g. wrapping the normal File product, which needs at least a
> filename, it has it's own form, but the CMF 'New...' form is
> just radio buttons and an ID field, so you get an 'expected 3
> got 2' error, and so on...

Believe it or not, this is actually "by design".  The issue is
that maintaining separate "contstruction" and "editing" UIs is
error-prone;  we chose to require that content be addable
through a uniform interface.

If you need to add a product which absolutely *must* have more
arguments to be constructed, then you'll have to do some
extra work.  E.g.:

 1. Make a ScriptableTypeInformation object instead.

 2. Have the script be / return a DTML method with the
    constructor form, which then POSTs to the "real"
    constructor method.

or else, 

 2. Have the STI method supply default values for all the
    non-ID arguments to the constructor, then edit them
    in the "initial_view".

> 
> Perhaps that form needs to be replaced with one with no ID
> box, that goes to a second form, which would be either the
> default (just asking for an ID or perhaps an option to
> auto-generate), or one specified when building an FTI
> type.....?  Would it then follow to have the 'Factory
> Method in Product' be instead the Form?

I'm not parsing that last;  of course, you are free to replace the 'folder_factories' skin method with one which does whatever
you need:  e.g., it might auto-generate the ID.  Trading away
the "uniform construction interface" will be incur non-trivial
consts, however, as scripts which assume it won't work (e.g.,
code which constructs content instances programmatically).

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@digicool.com
Digital Creations     "Zope Dealers"       http://www.zope.org