create ZClass instances in Python scripts
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? Cheers, Arkaitz.
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
On 05 May 2001 09:13:47 -0400, Jim Washington wrote:
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)
Thanks! that works, but what I'm doing now is passing the original context.REQUEST over to the constructor. It seems to be a good solution as well
-- Jim Washington
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (2)
-
Arkaitz Bitorika -
Jim Washington