[Zope] Copying objects in ZODB programmatically

Peter Sabaini sabaini@inode.at
Fri, 12 Apr 2002 20:21:29 +0200 (CEST)


Hmm... why do you "import Zope" -- do you want to manipulate the ZODB 
from outside of Zope?

On Fri, 12 Apr 2002, Noel Duffy wrote:

> I am trying to make a copy of an object in my ZODB using
> manage_copyObjects and manage_pasteObjects. I have code
> like this:
> 
>     import Zope
>     app=Zope.app()
>     x=app.manage_copyObjects([app['getad'].id])
>     app.manage_pasteObjects(x)
> 
> This raises an exception, like so:
> 
> Traceback (innermost last):
>   File "test.py", line 9, in ?
>     app.manage_pasteObjects(x)
>   File "lib\python\OFS\CopySupport.py", line 203, in manage_pasteObjects
>     self._verifyObjectPaste(ob)
>   File "lib\python\OFS\CopySupport.py", line 393, in _verifyObjectPaste
>     if getSecurityManager().validate(None, parent, None, meth):
>   File "/MC2\lib\python\AccessControl\SecurityManager.py", line 139, in validate
> 
>     self._context)
>   File "/MC2\lib\python\AccessControl\ZopeSecurityPolicy.py", line 211, in valid
> ate
>     raise 'Unauthorized', (
> Unauthorized: You are not authorized to access <em>methodAdd</em>.
> 
> However, I cannot see how to have my script authenticate itself to
> the ZODB so I can do the copy/paste. Can anyone tell me what I need
> to do here? Do I need to use 
> Zope.AccessControl.SecurityManagement.newSecurityManager somehow?
> 
> I'm using Zope 2.2.4, which for reasons too long to go into here I
> cannot change.
> 
> Thanks in advance,
> 
> Noel.
> 
>