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.' And I don't get it. I thought that by making my object inherit from 'OFS.SimpleItem.Item', I get cut&paste support. Can someone explain? What's the solution to make 'paste' functionality work? Or again, are there alternative tricks for moving objects around, besides 'manage_pasteObjects()'? Regards, Vio
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?
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? 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.
* 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
No, I get the same error.
OK, good.
class SaleOrder( Products.ZCatalog.CatalogAwareness.CatalogAware, Persistent, Acquisition.Implicit, AccessControl.Role.RoleManager, OFS.ObjectManager.ObjectManager, OFS.SimpleItem.Item, ):
SimpleItem already inherits from Persistent, Acquisition.Implicit, and AccessControl.Role.RoleManager, so you should be able to scratch them, and lessen the definition to
class SaleOrder( Products.ZCatalog.CatalogAwareness.CatalogAware, OFS.ObjectManager.ObjectManager, OFS.SimpleItem.Item, ):
# MY NOTE: changed meta_type to 'Folder' so as to enable 'paste' meta_type = 'Folder' # meta_type = 'SaleOrder'
Ah. Most likely a rights problem, then.
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.
Nah, it's better to set up it as protected to a certain right. security.declarePublic('View', 'my_public_stuff') will set your function so that everybody that has "View" rights can call the function. Then you need to set up anonymous so it has "View" rights, but thats default.
participants (3)
-
blob@sympatico.ca -
Lennart Regebro -
vmilitaru@sympatico.ca