[Zope-CMF] Re: Invoke factory?

Tres Seaver tseaver@zope.com
08 Jul 2002 13:07:49 -0400


On Mon, 2002-07-01 at 12:18, Carl Rendell wrote:
> I'll put this on the list for consumption...
> 
> I've been working with an update package creates copies of all 
> items created with ZClass based products, and creates a new version 
> from a folder based equivalent. This is all done via a python 
> script implemented as an external method. It's being performed on a 
> rather old platforms - Zope 2.4.1/CMF 1.1 , Zope 2.4.1/CMF 1.2
> 
> In my testing I found some strange behavior.. When attempting to 
> create a copy of the object using invokeFactory(), I would receive 
> the traceback listed below.
> 
> After performing more testing, I found that invokeFactory() DOES 
> function in this environment, but ONLY when the portal_type is 
> configured to use a file based product. If the portal_type is 
> configured to use a ZClass based product, the traceback rears its 
> ugly head.
> 
> At this point I understand the circumstances for the behavior, and 
> have a work-around so I'm not going into the problem any deeper. To 
> sum up my experience...
> 
> someFolderObject.invokeFactory('myobjectid','portal_type')
> 
> Is the preferred method for adding content, but can be a challenge 
> to use if your products are ZClass based.

I can create ZClass-based content using invokeFactory using the
latest CMF CVS.  In order to make it go, I delete the
'YourZClassHere_add' DTML method and replace it with a Python Script
of the same name, whose body looks like::

  ## Script (Python) "ZDocument_add"
  ##bind container=container
  ##bind context=context
  ##bind namespace=
  ##bind script=script
  ##bind subpath=traverse_subpath
  ##parameters=id, **kw
  ##title=
  ##
  kw['id'] = id
  context.ZDocument.createInObjectManager(id=id, REQUEST=kw)

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com