Hi, I'm writing a product and I have a little trouble with copy & paste support. My product defines three clases: ZSimpleMenu, ZSimpleMenuItem and ZSubMenuItem. The first one is a container for the other two. The last two have no sense outside a ZSimpleMenu, so I don't want them to be listed on the "global" add list, only on the ZSimpleMenu add list. In order to acomplish this I have registered (registerClass) only ZSimpleMenu, and store on ZSimpleMenu.all_meta_types the meta types of the two Z*Items. all_meta_types = ( {'name': 'Menu Item', 'action': 'manage_addMenuItemForm' }, {'name': 'Submenu Item', 'action': 'manage_addSubmenuItemForm' }, ) This does work, I can add objects as expected, but copy & paste don't work for Z*Items. When I try to copy/paste a ZSimpleMenuItem (id == m0100) within a ZSimpleMenu I get a "The object m0100 does not support this operation" error message. Copy/paste does work from ZSimpleMenu. All three objects inherit from OFS.SimpleItem.Item so I suspect that the problem is related to the way I'm registering the classes. What's the right way to register the Z*Items so I can copy & paste them, and they don't appear on the global add list? TIA -- //// (@ @) ---------------------------oOO----(_)----OOo------------------------ Los pecados de los tres mundos desapareceran conmigo. Alexis Roda - Universitat Rovira i Virgili - Reus, Tarragona (Spain) --------------------------------------------------------------------
On Mon, 2003-10-13 at 04:01, Alexis Roda wrote:
I'm writing a product and I have a little trouble with copy & paste support.
My product defines three clases: ZSimpleMenu, ZSimpleMenuItem and ZSubMenuItem. The first one is a container for the other two.
<snip>
I can add objects as expected, but copy & paste don't work for Z*Items.
If memory serves, copy/paste support is provided by the *container* object, not the object being copied and pasted. Thus, your container works fine because you're copying it in and out of Folder objects that provide support. But your inner objects don't work because ZSimpleMenu doesn't provide them with copy/paste support. Have ZSimpleMenu inherit from Folder instead of SimpleItem and see if that doesn't fix it. HTH, Dylan
I think you are out of luck because you can only paste things you are allowed to add. See OFS/CopySupport.py for the details. Stefan --On Montag, 13. Oktober 2003 13:01 +0200 Alexis Roda <arv@si.urv.es> wrote:
What's the right way to register the Z*Items so I can copy & paste them, and they don't appear on the global add list?
-- The time has come to start talking about whether the emperor is as well dressed as we are supposed to think he is. /Pete McBreen/
On Mon, 2003-10-13 at 08:38, Stefan H. Holek wrote:
I think you are out of luck because you can only paste things you are allowed to add. See OFS/CopySupport.py for the details.
Stefan
--On Montag, 13. Oktober 2003 13:01 +0200 Alexis Roda <arv@si.urv.es> wrote:
What's the right way to register the Z*Items so I can copy & paste them, and they don't appear on the global add list?
Oops... looks like I misunderstood the question. Sorry. If you *want* the add list to reflect something other than what's in all_meta_types, you can override the manage_main method of your container and make the add list say whatever you want it to. HTH, Dylan
Stefan H. Holek wrote:
I think you are out of luck because you can only paste things you are allowed to add. See OFS/CopySupport.py for the details.
Thanks, I'll take a look. The extrange thing is that I have written another product, a calendar wich is a container for CalendarItem (I'm not very original with the names :-) ). It works the same way, registers only the calendar, and CalendarItem goes on all_meta_types ... it works, I can C&P CalendarItems within a calendar. On the first versions, until I discovered all_meta_types, I registered both Calendar and CalendarItem, maybe this does some difference. Under Control_Panel/Products I can see Calendar, but no CalendarItem. Regards -- //// (@ @) ---------------------------oOO----(_)----OOo------------------------ Los pecados de los tres mundos desapareceran conmigo. Alexis Roda - Universitat Rovira i Virgili - Reus, Tarragona (Spain) --------------------------------------------------------------------
Stefan H. Holek wrote:
I think you are out of luck because you can only paste things you are allowed to add. See OFS/CopySupport.py for the details.
Stefan
--On Montag, 13. Oktober 2003 13:01 +0200 Alexis Roda <arv@si.urv.es> wrote:
What's the right way to register the Z*Items so I can copy & paste them, and they don't appear on the global add list?
I've made a very stupid mistake ... the name attrs on all_meta_types ('Menu Item', 'Submenu Item') don't match the meta_type of Z*Items ('Simple Menu Item', 'Simple Submenu Item'). I've updated all_meta_types and now it works. Thanks for your help -- //// (@ @) ---------------------------oOO----(_)----OOo------------------------ Los pecados de los tres mundos desapareceran conmigo. Alexis Roda - Universitat Rovira i Virgili - Reus, Tarragona (Spain) --------------------------------------------------------------------
participants (3)
-
Alexis Roda -
Dylan Reinhardt -
Stefan H. Holek