[Zope-CMF] CopySupport and FSPythonScripts?

Tres Seaver tseaver@palladion.com
Thu, 16 Aug 2001 11:15:59 -0400


seb bacon wrote:

> I can't copy objects inside my Portal programmatically. 
> 
> I'm trying to create a default set of objects for each user when they
> sign up - a hierarchy of objects, in fact.  I figured the best way
> would be to set up a 'template' in my portal root, called
> 'default_template', which is a folder full of methods, folders, etc.
> 
> In MembershipTool I do something like this:
> 
>             layout = getattr(parent, 'default_template', None)
>             if layout:
>                 obs = layout.objectIds()
>                 copy_data = parent.manage_copyObjects(obs)
>                 f.manage_pasteObjects(copy_data)
> 
> I put a single, web-based DTML method in the 'default_template' folder.
> However, the manage_copyObjects line throws a 'this operation not
> supported' type of error.  I delved deeper.  The bit which fails is in
> CopySupport, where cb_isCopyable tests the _p_jar attribute of the
> object to be copied.  This is where I get lost, since I only vaguely
> know about such things.  I can still copy the object TTW, though.
> 
> I noticed when running it through the debugger that the DTML Method in
> question actually thinks it is an FSPythonScript.  Why would this be?  Is it
> anything to do with the failed copy?


Probably you have a name clash with an FSPythonScript.  Your code
tries to copy the items from 'parent', rather than from 'layout',
which could be the real source of the problem.  Try::

   layout = getattr(parent, 'default_template', None)
   if layout:
       obs = layout.objectIds()
       copy_data = layout.manage_copyObjects(obs)
       f.manage_pasteObjects(copy_data)


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