Adding ZClass Instances via Python
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
Edmund Goppelt wrote:
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.
self = self.this() ob = self.Control_Panel.Products.SomeProduct.SomeZClass(id) ob._setId(id) ...Other inits such as property sheets, etc... self._setObject(id, ob) -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
participants (2)
-
Casey Duncan -
Edmund Goppelt