Salve,<br>mi trovo nella necessita&#39; di fare numerosi e veloci upload automatici <br>di files secondo questo schema<br>1) crea una folder<br>2) upload di due files<br><br>Nella sue essenza il codice e&#39; questo<br><br>
from mechanize import Browser<br>import os<br>import random<br><br><br>def mkdir(br,path,name,desc):<br>&nbsp;&nbsp;&nbsp; br.open(&quot;http://192.168.2.26:18080%(path)s/createObject?type_name=Folder&quot; %{&#39;path&#39; :path})<br>&nbsp;&nbsp;&nbsp; br.select_form(name=&quot;edit_form&quot;)<br>
&nbsp;&nbsp;&nbsp; br[&#39;title&#39;] = name<br>&nbsp;&nbsp;&nbsp; br[&#39;description&#39;] = desc<br>&nbsp;&nbsp;&nbsp; response = br.submit()<br><br><br>def copy(br,path,src,dest):<br>&nbsp;&nbsp;&nbsp; res = br.open(&quot;http://192.168.2.26:18080%(path)s/createObject?type_name=File&quot; %{&#39;path&#39; : path})<br>
&nbsp;&nbsp;&nbsp; res = br.select_form(name=&quot;edit_form&quot;)<br>&nbsp;&nbsp;&nbsp; edit_form = [j for j in br.forms() if <a href="http://j.name">j.name</a> == &#39;edit_form&#39;][0]<br>&nbsp;&nbsp;&nbsp; file_file = [j for j in edit_form.controls if <a href="http://j.name">j.name</a> == &#39;file_file&#39;][0]<br>
&nbsp;&nbsp;&nbsp; file_file.add_file(file_object=file(src,&#39;rb&#39;),filename=dest)<br>&nbsp;&nbsp;&nbsp; response = br.submit()<br><br><br>if __name__ == &#39;__main__&#39;:<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; br&nbsp;&nbsp; = Browser()<br><br><br clear="all"><br>-- <br>luigi<br>
<br>