Copy and paste is not working in custom folder product
Hi there, I've created a custom folder which has some addable products defined inside it. When I add such a product and try to copy and paste it, I get this traceback: The object test does not support this operation Traceback (innermost last): File /home/zope/lib/python/ZPublisher/Publish.py, line 214, in publish_module File /home/zope/lib/python/ZPublisher/Publish.py, line 179, in publish File /home/zope/lib/python/Zope/__init__.py, line 201, in zpublisher_exception_hook File /home/zope/lib/python/ZPublisher/Publish.py, line 165, in publish File /home/zope/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: manage_pasteObjects) File /home/zope/lib/python/ZPublisher/Publish.py, line 102, in call_object (Object: manage_pasteObjects) File /home/zope/lib/python/OFS/CopySupport.py, line 199, in manage_pasteObjects File /home/zope/lib/python/OFS/CopySupport.py, line 374, in _verifyObjectPaste Copy Error: (see above) The folderish product derives from ObjectManager. The addable products derive from OFS.SimpleItem.Item, Persistent, Acquisition.Implicit, AccessControl.Role.RoleManager Note that these addable products do have an extra object set inside them. Should this one somehow define copysupport as well? Anybody have any clue why copy and paste is not working? What should I investigate? If this post contains too little information I'll just release my code with this bug next week so people can study it then. :) Regards, Martijn
At 04:17 PM 11/25/99 , Martijn Faassen wrote:
Hi there,
I've created a custom folder which has some addable products defined inside it. When I add such a product and try to copy and paste it, I get this traceback:
The object test does not support this operation
Traceback (innermost last): File /home/zope/lib/python/ZPublisher/Publish.py, line 214, in publish_module File /home/zope/lib/python/ZPublisher/Publish.py, line 179, in publish File /home/zope/lib/python/Zope/__init__.py, line 201, in zpublisher_exception_hook File /home/zope/lib/python/ZPublisher/Publish.py, line 165, in publish File /home/zope/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: manage_pasteObjects) File /home/zope/lib/python/ZPublisher/Publish.py, line 102, in call_object (Object: manage_pasteObjects) File /home/zope/lib/python/OFS/CopySupport.py, line 199, in manage_pasteObjects File /home/zope/lib/python/OFS/CopySupport.py, line 374, in _verifyObjectPaste Copy Error: (see above)
The folderish product derives from ObjectManager.
The addable products derive from OFS.SimpleItem.Item, Persistent, Acquisition.Implicit, AccessControl.Role.RoleManager
Note that these addable products do have an extra object set inside them. Should this one somehow define copysupport as well?
Anybody have any clue why copy and paste is not working? What should I investigate? If this post contains too little information I'll just release my code with this bug next week so people can study it then. :)
Well, let's start with CopySupport.py. It'll throw above warning in several cases, but the line number in your traceback points to the last case in this method. It first checks if the meta_type of the object copied is addable to the target container (it checks for this with all_meta_types). Then it'll check if the user has permission to add the copied object to this container. One of these two checks fails. You can check this code yourself, it's line 332 up to 369 of CopySupport.py. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
Martijn Pieters wrote:
At 04:17 PM 11/25/99 , Martijn Faassen wrote: [snip my problem] Well, let's start with CopySupport.py.
It'll throw above warning in several cases, but the line number in your traceback points to the last case in this method.
Right, I saw that and I looked at that code, but then I felt vague and got lost. :)
It first checks if the meta_type of the object copied is addable to the target container (it checks for this with all_meta_types). Then it'll check if the user has permission to add the copied object to this container.
One of these two checks fails. You can check this code yourself, it's line 332 up to 369 of CopySupport.py.
Oddly enough though, it doesn't seem like these checks *should* fail: * I can add a new object of the same meta_type to that folder, in the management screen -- so it should be part of all_meta_types * Because I can do that (logged in as manager) it doesn't seem to be a security check that fails as well. Since apparently it has to be one of these two I'll continue my search, but it certainly is odd. Perhaps it's a matter of strangely configured security. And I do hack around meta_types a bit so it may be that as well. Regards, Martijn
Martijn Faassen wrote:
Anybody have any clue why copy and paste is not working? What should I investigate? If this post contains too little information I'll just release my code with this bug next week so people can study it then. :)
Do rename and import fail with the same message? One version of PythonMethods had a bug which looked just like this. It was introduced when I moved some HTMLFiles (in particular, the add-a-new-PM dtml file) into a subdirectory of the product. I was never able to track down the exact cause, but changing how I loaded my .dtml files fixed the problem. Cheers, Evan @ 4-am
Evan Simpson wrote:
Martijn Faassen wrote:
Anybody have any clue why copy and paste is not working? What should I investigate? If this post contains too little information I'll just release my code with this bug next week so people can study it then. :)
Do rename and import fail with the same message? One version of PythonMethods had a bug which looked just like this. It was introduced when I moved some HTMLFiles (in particular, the add-a-new-PM dtml file) into a subdirectory of the product. I was never able to track down the exact cause, but changing how I loaded my .dtml files fixed the problem.
Good question.. I'll check. rename -- yup, fails on the same error. import/export -- hm. reminds me to add an import/export tab. Right now the 'export..' button can be used though. Yes, also the same error. Thanks for this clue! I don't know what to do now, though. My .dtml files don't reside in subdirectories. Though it's very well possible it's due to some of the other odd stuff I do. :) How'd you change the way you loaded your .dtml files? I suppose I should just release what I have next week to have people look at it. Regards, Martijn
Martijn Faassen wrote:
Thanks for this clue! I don't know what to do now, though. My .dtml files don't reside in subdirectories. Though it's very well possible it's due to some of the other odd stuff I do. :) How'd you change the way you loaded your .dtml files?
I changed manage_addPythonMethodForm=HTMLFile('www/methodAdd', globals()) to _www = os.path.join(package_home(globals()), 'www') manage_addPythonMethodForm=HTMLFile('methodAdd', _www) All I can figure is that loading the HTMLFile with a pathname instead of a basename somehow caused the problem. Cheers, Evan @ 4-am
Evan Simpson wrote:
Martijn Faassen wrote:
Thanks for this clue! I don't know what to do now, though. My .dtml files don't reside in subdirectories. Though it's very well possible it's due to some of the other odd stuff I do. :) How'd you change the way you loaded your .dtml files?
I changed
manage_addPythonMethodForm=HTMLFile('www/methodAdd', globals())
to
_www = os.path.join(package_home(globals()), 'www') manage_addPythonMethodForm=HTMLFile('methodAdd', _www)
All I can figure is that loading the HTMLFile with a pathname instead of a basename somehow caused the problem.
The exact equivalent can't be happening in my code right now; everything's in one directory right now. I *do* mess with meta_types, though. When I register a SimpleItem derived class with my Folderish object, I do an ugly hack to manually add it to its meta_types: # Form is the class of my Folderish object (deriving from ObjectManager) # fieldname is the meta_type of the field object I want to addable to # these forms # add this as an addable field to the form # for some reason we must use this tuple adding, # as setting meta_types to an empty list in Form # does not appear work; meta_types always seems to be a tuple. Form.meta_types = Form.meta_types +\ ({ 'name': fieldname, 'action': 'manage_add%sForm' % fieldname }, ) I imagine this kind of hack could wreck things. This is another hack: # add manage_add method for this field to the Form class # use FormHack to create the right add form setattr(Form, 'manage_add%sForm' % fieldname, FormHack(fieldname)) Where FormHack is a class I use instead of HTMLFile(). The FormHack instance simply gives back the HTML I want when called. I reported the weird grief HTMLFile() gave me earlier on the list. Anyway, this hack is another suspect. And there are other tricks I've used to shield my code from Zope's machinery. Perhaps this has given anybody any clues as to my problems? Regards, Martijn
participants (4)
-
Evan Simpson -
Martijn Faassen -
Martijn Faassen -
Martijn Pieters