[Zope-CMF] How to add a non-empty instance of a content type

Sam Brauer sam@webslingerz.com
Wed, 11 Jun 2003 16:28:06 -0400


Dieter,

I just wanted to say thanks.  I'm busy with other issues right now, but 
I think you gave me some leads I will be able to use later, particularly 
the part about using __of__.  I suppose I'll finally have to come to 
grips with acquisition at the Python level :)

Regarding Plone, the last time I checked, when you select a new type to 
create, it creates an "empty" instance with a timestamp-based name.
You can then change the name on the edit form, and Plone renames the 
object... but if you were to leave the edit form without saving, the 
"empty" object would still exist.
(Maybe you're referring to the CVS version, which I haven't taken the 
time to check out.)

- Sam

Dieter Maurer wrote:
> Sam Brauer wrote at 2003-6-10 10:51 -0400:
>  > ...
>  > I know you can change the "immediate view" to the edit form instead of 
>  > the metadata form.  But what I'd really like to be able to do is present 
>  > the user with a customized version of the edit form that includes an ID 
>  > field, and not actually store an object until the user submits the edit 
>  > form.  At that time, besides doing any type-specific validation, I would 
>  > need to make sure that the ID is valid.  Then if there's anything 
>  > invalid, I would re-render the edit form with the data from the request 
>  > and some error messages.
> 
> You would need to customize the UI, more precisely, the part
> dealing with object creation. Instead of asking for type
> and id on one form and then switching to the creation action,
> you would only ask for the type, then go to a second form
> asking for id and all relevant information and only then
> transfer to the creation action.
> This action would create the object and then update its content
> with the collected information, in a single transaction.
> 
>  > My custom types can do the validation and form re-rendering, but they 
>  > can only edit existing objects.
> 
> I solved this problem by creating a temporary object, loosely
> mapped into the Zope hierarchy (via "__of__").
> When everything was right, the object was finally embedded
> into the site with "_setObject".
> Adapting this approach for CMF would require some non-trivial
> changes.
> 
>  > My types have a factory method that 
>  > takes as arguments an ID and an optional REQUEST.  I'm guessing there's 
>  > some way a script could call that constructor method and pass a REQUEST 
>  > to it, but I haven't been able to figure out the proper way to do that yet.
> 
> The "constructContent" method takes arguments
> "type_name", "destinationFolder", "id", "RESPONSE".
> Any additional arguments are passed on to your factory.
> 
>  > Can anyone offer any advice on handling an "add" form that doesn't store 
>  > a new object until the add form has been successfully submitted?
> 
> "Plone" solved this problem in a more general way.
> Maybe, you can learn from their code.
> 
> 
> Dieter


-- 
Sam Brauer
Systems Programmer
sam@webslingerZ.com