manage_cutObjects/manage_pasteObjects problem ...

View: New views
5 Messages — Rating Filter:   Alert me  

manage_cutObjects/manage_pasteObjects problem ...

by Ajay Deshpande-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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)
...

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:
<HTML>
<HEAD>
<TITLE>Not Supported</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<FORM ACTION="manage_main" METHOD="GET" >
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="10">
<TR>
  <TD VALIGN="TOP">
  <BR>
  <CENTER><B><FONT SIZE="+6" COLOR="#77003B">!</FONT></B></CENTER>
  </TD>
  <TD VALIGN="TOP">
  <BR><BR>
  <CENTER>
  The object <em>dtmij.txt</em> does not support this operation.
  </CENTER>
  </TD>
</TR>
<TR>
  <TD VALIGN="TOP">
  </TD>
  <TD VALIGN="TOP">
  <CENTER>
  <INPUT TYPE="SUBMIT" VALUE="   Ok   ">
  </CENTER>
  </TD>
</TR>
</TABLE>
</FORM>
</BODY></HTML>
....

I cannot perform this operation directly using the ZMI also. So it is not a problem with the script. Some issue in CopySupport. I searched for the resolution and found that CopySupport needs to be patched. But I couldnt find the patch anywhere.

My Zope is 2.9.4-final, Python2.4.3.

Any help is greatly appreciated.

TIA,
Aj

"And the trees are all kept equal
By hatchet, axe, and saw"

_______________________________________________
Zope maillist  -  Zope@...
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: manage_cutObjects/manage_pasteObjects problem ...

by Giampiero Benvenuti :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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@...
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: manage_cutObjects/manage_pasteObjects problem ...

by Dieter Maurer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
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: manage_cutObjects/manage_pasteObjects problem ...

by Paul Winkler-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
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: manage_cutObjects/manage_pasteObjects problem ...

by Dieter Maurer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
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 )
LightInTheBox - Buy quality products at wholesale price