[Zope] Programmatically creating instances of a ZClass

Gouzy Nicolas nicolas@opixido.com
Thu, 5 Sep 2002 17:20:59 +0200


Sorry, write:
obj=3Dcontext.MyProduct.createInObjectManager(id, {})

On Thursday 05 September 2002 16:59, Borislav wrote:
> 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"
> >
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> > # MyProduct_add source                             #
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> >
> > Parameter List:
> > id, REQUEST=3DNone
> >
> > Code:
> > obj=3Dcontext.MyProduct.createInObjectManager(id=3Did, {})
> >
> > if REQUEST is not None:
> >     try:
> >          u=3Dcontext.DestinationURL()
> >     except:
> >          u=3DREQUEST['URL2']
> >     REQUEST.RESPONSE.redirect(u+'/manage_workspace')
> >
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
> >
> > Now, you can write in a Python Script:
> > container.manage_addProduct['MyProduct'].MyProduct_add(id=3D'myBeauti=
fulObj
> >ect')
>
> Zope has a problem with the first line:
> obj=3Dcontext.MyProduct.createInObjectManager(id=3Did, {})
>
> 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 suggestio=
ns?
>
> --Borislav

--=20
Nicolas Gouzy
Chef de Projet / Ing=E9nieur de D=E9veloppement

OPIXIDO
9, cit=E9 paradis 75010 Paris
tel : 01 40 22 92 46 ou 47
fax : 01 40 22 92 44