[Zope] HELP? Copy and Paste in Python

Kevin Dangoor kid@kendermedia.com
Fri, 13 Aug 1999 14:32:26 -0400


Hi,

    Having had no luck in copying and pasting my objects in DTML, I decided
to try an External Method. I wrote a function that takes two arguments: from
object and to object. It is supposed to copy all of the objects in the from
object (a Folder in this case) into the to object (a ZClass instance that
inherits from CatalogAware and ObjectManager).

Here is the code:

def candp(fobj, tobj):
  "Copy and paste"

  ids = fobj.objectIds()
  if not ids:
    return
  cdata = fobj.manage_copyObjects(ids)
  tobj.manage_pasteObjects(cdata)

I get an error that the object that is referred to is not found. Here is the
last part of the traceback I get:

  File C:\Program Files\Byproducts\lib\python\DocumentTemplate\DT_Util.py,
line 315, in eval
    (Object: candp(fobj, this()))
  File <string>, line 0, in ?
  File C:\Program
Files\Byproducts\lib\python\Products\ExternalMethod\ExternalMethod.py, line
246, in __call__
    (Object: candp)
    (Info: ((<Folder instance at 00B4F2D0>, <KMArticle instance at
01650710>), {}, None))
  File C:\Program Files\Byproducts\Extensions\art.py, line 28, in candp
    (Object: ElementWithAttributes)
  File C:\Program Files\Byproducts\lib\python\OFS\CopySupport.py, line 198,
in manage_pasteObjects
    (Object: CatalogAware)
Copy Error: (see above)


As you can see, the DTML is calling the candp External Method with "fobj",
with is a Folder and this() which is a KMArticle instance.

Any hints?

Thanks,
Kevin