[Zope-dev] Adding ZClass Instances via Python

Edmund Goppelt goppelt@goppelt.net
Fri, 16 Mar 2001 16:19:51 -0500


Ok, I know there's a howto with a working solution to this problem,
but this is *still* killing me:

How does one add a ZClass Instance in a way analagous to adding, say,
a DTML Document in a Python script?

With the dtml document, it's easy:

container.manage_addProduct['OFSP'].addDTMLDocument('anid', 'atitle','a file')

I've tried the following, which don't work, as well as a variety of
permutations and combinations involving container & context.

constructor.Bill_add(None, context)
constructor.Bill_add(container, cons, REQUEST)

# Is this how one sets the REQUEST variable from a script?  Can the
# REQUEST variable be set from any valid Zope object, e.g,:
# Anywhere.Anyobject.REQUEST.set('dfkjd', 123) will change the
# variable dfkjd in the REQUEST object?

container.REQUEST.set('id', '9389483484') 
container.REQUEST.set('title', 'a title')
constructor=container.manage_addProduct['Bill']

The problem seems to have something to do with the getting the
contexts right and getting the REQUEST info. passed to the
constructor, but I'm just guessing at this point.

Bill_add is the standard dtml method constructor created by the ZClass product.

-- 

Ed Goppelt