[Zope] create ZClass instances in Python scripts

Jim Washington jwashin@vt.edu
Sat, 05 May 2001 09:13:47 -0400


Arkaitz Bitorika wrote:
> 
> Hi,
> 
> Is it possible to create programmatically ZClass instances from Python
> scripts? I haven't been able to do it.
> I have the next thing in my Python script:
>     folder.manage_addProduct['MyProduct'].manage_addMyZClass_py(myId)
> And then I have a Python Script called "manage_addMyZClass_py" in
> "MyProduct" that does simply this:
>     container.MyZClass.createInObjectManager(id)
> All this gives me the next message:
>                    Error Type: TypeError
>                    Error Value: not enough arguments; expected 3,got 2
> This happens when calling createInObjectManager(), because it expects a
> REQUEST object, but I don't have one! It won't accept a None REQUEST
> object either.
> Any hint?

container can acquire a REQUEST object.  Try:

container.MyZClass.createInObjectManager(id, container.REQUEST)

-- Jim Washington