Salve,
mi trovo nella necessita' di fare numerosi e veloci upload automatici
di files secondo questo schema
1) crea una folder
2) upload di due files

Nella sue essenza il codice e' questo

from mechanize import Browser
import os
import random


def mkdir(br,path,name,desc):
    br.open("http://192.168.2.26:18080%(path)s/createObject?type_name=Folder"
%{'path' :path})
    br.select_form(name="edit_form")
    br['title'] = name
    br['description'] = desc
    response = br.submit()


def copy(br,path,src,dest):
    res = 
br.open("http://192.168.2.26:18080%(path)s/createObject?type_name=File"
%{'path' : path})
    res = br.select_form(name="edit_form")
    edit_form = [j for j in br.forms() if j.name == 'edit_form'][0]
    file_file = [j for j in edit_form.controls if j.name == 'file_file'][0]
    file_file.add_file(file_object=file(src,'rb'),filename=dest)
    response = br.submit()


if __name__ == '__main__':

    br   = Browser()



-- 
luigi
_______________________________________________
Plone-IT mailing list
Plone-IT@lists.plone.org
http://lists.plone.org/mailman/listinfo/plone-it
http://www.nabble.com/Plone---Italy-f21728.html

Rispondere a