[Zope-CMF] Easy Content-Add script
Tres Seaver
tseaver@zope.com
Fri, 09 Nov 2001 17:12:24 -0500
Jan Torben Heuer wrote:
> I think many people have already done this, althoug I can't find any
> instructions.
>
> I want to create a very simple news_add form. It should be a mix of the
> metadata and the lead-in/body. Additionally I would like to set the path
> where this item will be saved..
> The only thing I could found is, how to generate an auto-ID.
>
> The invokeFactory can just create an object, not set it's properties?
>
> I tried to read the metadata_edit and the news_edit script, but I couldn't
> figure out what these script does.
>
> Any hints?
Something like (depending on how you name the fields on your form)::
## Script (Python) "simplenewsitem_edit"
##parameters=title, description, subject, text, choice=' Change '
##title=Edit a Simple News Item
context.edit(text, description)
context.setTitle( title )
context.setSubject( subject )
qst='portal_status_message=Simple+News+Item+changed.'
if choice == ' Change and View ':
target_action = context.getTypeInfo().getActionById( 'view' )
else:
target_action = context.getTypeInfo().getActionById( 'edit' )
context.REQUEST.RESPONSE.redirect( '%s/%s?%s' % ( context.absolute_url()
, target_action
, qst
) )
Tres.
--
===============================================================
Tres Seaver tseaver@zope.com
Zope Corporation "Zope Dealers" http://www.zope.com