Re: [Zope] manage_cutObjects/manage_pasteObjects problem ...

2008-08-02 Thread Dieter Maurer
Giampiero Benvenuti wrote at 2008-7-25 15:20 +0200:
> ...
>it should be something like this:
>...
>src=context.your_cut_context[obj_id]
>context.your_cut_context.manage_cutObjects([src])

"manage_cutObjects" takes a sequence of ids (or a single id)
as input (not the real objects).

>dst=context.your_paste_context
>dst.manage_pasteObjects(src)

"manage_pasteObjects" takes the return value of "manage_cut/copyObjects"
as input not the real objects.



-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] manage_cutObjects/manage_pasteObjects problem ...

2008-07-30 Thread Paul Winkler
Just a quick note:

On Fri, Jul 25, 2008 at 03:20:23PM +0200, Giampiero Benvenuti wrote:
> I think the problem is your 4th line: copy_info = 
> obj_parent.manage_cutObjects((context.getId()))
> copy_info should be the object you want to cut
>
> it should be something like this:
> ...
> src=context.your_cut_context[obj_id]
> context.your_cut_context.manage_cutObjects([src])
>
> dst=context.your_paste_context
> dst.manage_pasteObjects(src)

Sorry Giampiero, you're just guessing, and you're guessing wrong.  The
original poster's code was correct*.  Dieter's suggestion is a better
approach to troubleshoot this problem.


*well, almost correct. There's a common Python mistake on one line:

 copy_info = obj_parent.manage_cutObjects((context.getId()))
   
You think you're creating a tuple there, but you're not.
To create a tuple of size 1, you need a trailing comma:

 copy_info = obj_parent.manage_cutObjects((context.getId(),))

But that's not causing your problem; manage_cutObjects() "helpfully"
wraps a string argument in a tuple for you.

-- 

Paul Winkler
http://www.slinkp.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] manage_cutObjects/manage_pasteObjects problem ...

2008-07-26 Thread Dieter Maurer
Ajay Deshpande wrote at 2008-7-23 10:36 +0530:
>Ive been trying to cut objects from one context and paste them into another
>using a script python. But I get a "CopyError" when I try doing this. This
>is my code snippet and the traceback ...
>
>Snippet...
>...
>obj = context.restrictedTraverse(path)
>obj_parent = obj.aq_inner.aq_parent
>dest_folder = context.Dest # this is a folder object
>copy_info = obj_parent.manage_cutObjects((context.getId()))
>dest_folder.manage_pasteObjects(copy_info)
>...
>
>Traceback:
>Traceback (innermost last):
>  Module ZPublisher.Publish, line 115, in publish
>  Module ZPublisher.mapply, line 88, in mapply
>  Module ZPublisher.Publish, line 41, in call_object
>  Module OFS.CopySupport, line 194, in manage_pasteObjects
>  Module OFS.CopySupport, line 527, in _verifyObjectPaste
>Copy Error:

Usually, Zope error messages and tracebacks are quite informative.

The unhelpful error messages from "CopySupport" are an exception.
For them, you must look at the Code (near line 527 of "CopySupport.py")
and check, what it really did not like.



-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] manage_cutObjects/manage_pasteObjects problem ...

2008-07-25 Thread Giampiero Benvenuti


On Jul 23, 2008, at 7:06 AM, Ajay Deshpande wrote:


Hi all:

Ive been trying to cut objects from one context and paste them into  
another using a script python. But I get a "CopyError" when I try  
doing this. This is my code snippet and the traceback ...


Snippet...
...
obj = context.restrictedTraverse(path)
obj_parent = obj.aq_inner.aq_parent
dest_folder = context.Dest # this is a folder object
copy_info = obj_parent.manage_cutObjects((context.getId()))
dest_folder.manage_pasteObjects(copy_info)
...


I think the problem is your 4th line: copy_info =  
obj_parent.manage_cutObjects((context.getId()))

copy_info should be the object you want to cut

it should be something like this:
...
src=context.your_cut_context[obj_id]
context.your_cut_context.manage_cutObjects([src])

dst=context.your_paste_context
dst.manage_pasteObjects(src)
...

Let me know if it works for you,

Giampiero


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )