[Zope] Moving files using python scripts

Satheesh Babu vattekkat.babu at verizon.net
Sun Dec 21 20:36:28 EST 2003


Hi,

Yes, it is easily possible. Here is a python script (not tested) to do 
it. It takes two parameters, viz., target_folder_path=path_to_target and 
move_ids=[item_id1, item_id2 etc.]. items are expected to be in the 
current folder.

if len(move_ids) > 0:
     try:
         target_folder = context.restrictedTraverse(target_folder_path)
     except:
         return "ERROR: Target folder doesn't exist"
     clip = o_parent.manage_cutObjects(ids=move_ids)
     target_folder.manage_pasteObjects(clip)


If you are not authenticating users, you might want to give "Manager" 
proxy to this script.

Sample values passed from your form might look like
path_to_target:
      /mysite/myapp/myfolder/
      ../myfolder/
      ./
move_ids:
      []
      ['document1', 'document2']

--
Vattekkat Satheesh Babu
http://vsbabu.org/



David Sumner wrote:
> Hello,
> 
> I am trying to develop an application that allows moving of items from 
> one folder to another without using the ZMI. The application allows them 
> to create folders for archival purposes. Items are created in the New 
> folder. They view these items in the New folder and can move them to any 
> folder that they may have created. I am populating a drop down box with 
> a list of folders, they check the items they want to move, choose the 
> folder and click the Move To button. That posts to a python script. I am 
> able to cut the checked items but how do I call the past function on an 
> folder when I have the id of the folder I want to paste the items in. I 
> can reference the folder directly, but that does not allow them to 
> choose the folder from the drop down list. Is it possible to 
> programmatically access a folder to paste when given the id of that folder?
> 
>  
> 
> Thanks,
> 
> David
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Zope maillist  -  Zope at 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 )






More information about the Zope mailing list