[Zope] How to add ZClass instances from Python Script ? Help needed

Jim Washington jwashin@vt.edu
Thu, 05 Apr 2001 16:01:09 -0400


I have had good luck with:

container.manage_addProduct['nameofthefolder_under_Control_Panel_Products'].ZClassClass.createInObjectManager(thenewID,container.REQUEST)

Here is some actual code from initialization of one of my ZClasses,
which creates 5 instances of another ZClass:

for k in range(1998,2003):
  dataname = 'A'+str(k)
  t = 'Actuals for %s-%s' % (k-1,k)
 
container.manage_addProduct['HSTWProduct'].HSTWDataClass.createInObjectManager(dataname,container.REQUEST)
  container[dataname].manage_changeProperties(title = t)

-- Jim Washington

"Upton, Sean" wrote:
> 
> Unfortunately, this doesn't work from a PythonScript (can't use _setId,
> etc), only external methods.  I am trying to do the same thing, trying to
> port the technique (calling the ZClass constructor add method) from the dtml
> version, but I can't seem to get it right... anybody have any thoughts?
> 
> Sean
> 
> -----Original Message-----
> From: Casey Duncan [mailto:cduncan@kaivo.com]
> Sent: Wednesday, April 04, 2001 2:51 PM
> To: Anton A. Zotov
> Cc: zope@zope.org
> Subject: Re: [Zope] How to add ZClass instances from Python Script ?
> Help needed
> 
> "Anton A. Zotov" wrote:
> >
> > People, hi !
> >
> > I would appreciate somebody telling me how to programmatically add ZClass
> > instance from Python Script. Everything I tried won't work for the time
> > being  :-(
> >
> > Thanx,
> >
> > Anton
> >
> 
> Check out: http://www.zope.org/Members/tazzzzz/addZClasses
> 
> this should give you the info you need.