[Zope] Programmatically creating instances of a ZClass

Borislav borislavd@gmx.net
Thu, 05 Sep 2002 09:59:01 -0500


Gouzy Nicolas wrote:
> Your constructor "MyProduct_add" is a DTML Method, isn't it ?
> Delete it and replace by a Python Script called "MyProduct_add"
> 
> ======================================
> # MyProduct_add source                             #
> ======================================
> 
> Parameter List: 
> id, REQUEST=None
> 
> Code:
> obj=context.MyProduct.createInObjectManager(id=id, {})
>    
> if REQUEST is not None:
>     try:
>          u=context.DestinationURL()
>     except:
>          u=REQUEST['URL2']
>     REQUEST.RESPONSE.redirect(u+'/manage_workspace')
> 
> =======================================================
> 
> Now, you can write in a Python Script:
> container.manage_addProduct['MyProduct'].MyProduct_add(id='myBeautifulObject')
> 

Zope has a problem with the first line:
obj=context.MyProduct.createInObjectManager(id=id, {})

When I try to save the code I'm getting an error:

Zope has encountered an error while publishing this resource.
Error Type: SyntaxError
Error Value: non-keyword arg after keyword arg

When I comment out the first line, Zope accepts the code. Any suggestions?

--Borislav