[Zope] 'manage_pasteObjects()' problem

blob@sympatico.ca blob@sympatico.ca
Tue, 11 Dec 2001 14:22:30 -0500


* Lennart Regebro <lennart@regebro.nu> [011211 13:54]:

Hello Lennart, thanks for your reply.

> From: <vmilitaru@sympatico.ca>
> > When I execute the following python code (from within a method of an
> instantiated object):
> >
> > myClipboard = self.aq_parent.manage_cutObjects(id)
> > destination_folder = getattr(my_root_folder,'dest')
> > destination_folder.manage_pasteObjects(myClipboard)
> >
> > I get the error:
> > 'The object <my object id> does not support this operation.'
> 
> Can you cut and paste the objects manually from within the ZMI?

No, I get the same error.

> 
> > And I don't get it. I thought that by making my object inherit from
> 'OFS.SimpleItem.Item', I get cut&paste support.
> 
> What you get is inheritance of the "CopySource" object, and the
> manage_afterClone() functions that get called when you copy and paste. Have
> you inherited from any other objects?

class SaleOrder(
    Products.ZCatalog.CatalogAwareness.CatalogAware,
    Persistent,
    Acquisition.Implicit,
    AccessControl.Role.RoleManager,
    OFS.ObjectManager.ObjectManager,
    OFS.SimpleItem.Item,
    ):
    "Documentation string"

    # MY NOTE: changed meta_type to 'Folder' so as to enable 'paste'
    meta_type = 'Folder'
#   meta_type = 'SaleOrder'


> 
> You have the copy/paste support in OFS.CopySupport, both the basic
> "CopySource" and the "CopyContainer". These together does most of the work.
> It's basically a question of doing a _delObject() and a _setObject() with
> some checks around it.
> 

My cheesy workaround is to just change the meta_type like that, and 
surprizingly it works. My understanding of OFS.CopySupport.manage_pasteObjects()
 is that it chokes on the call to 'self._verifyObjectPaste(ob)' (line 216 on my source): the user I run manage_pasteObjects() as does not have permission to paste. Well, I must say that Zope totally lost me with its permissions and roles: a big big bug in my code is that part of my code should be available to public (user anonymous), but I just can't get rid of the authentication dialog (for reasons I totally don't understand, calls to "security.declarePublic('my_public_stuff')" seem utterly ineffective). I am guessing similar black magic happening here.

Kind regards,
Vio