On Wed, 2003-05-21 at 13:47, Dieter Maurer wrote:
Damon Butler wrote at 2003-5-20 14:53 -0500:
I'd like to write a script that I can run from the command line -- NOT a Python script object in Zope or even an external method -- that I can run to upload files into Zope. Here's some code that I'm using right now that, according to the documentation and examples I've seen for the urllib2 library, OUGHT to work:
I use "ZPublisher.Client". It is much easier then "urllib2".
Thanks for the tip. ZPublisher.Client looks very promising, but it doesn't work for me. It looks as if the program is choking on something. Very small files (text files or jpegs are what I tested) will successfully upload, but the script always chokes with an error anyway. Trying to upload "large" files (anything over a few dozen kb, say) cause the script to just hang and spin its wheels. I have to kill the process. The file does not get uploaded and no Traceback is created. Here's a sample command line and the resultant Traceback from an attempt to upload a small text file: ==================== % python Client.py -u me:mypasswd http://localhost:8080/manage_addFile id=smallTextFile.txt file:file=/home/damon/tmp/smallTextFile.txt Traceback (most recent call last): File "./Client.py", line 563, in ? main() File "./Client.py", line 556, in main headers, body = apply(f,(),kw) File "./Client.py", line 109, in __call__ if hasattr(v,'read'): return self._mp_call(kw) File "./Client.py", line 231, in _mp_call self.handleError('', ec, em, headers, response) File "./Client.py", line 170, in handleError raise t, RemoteException(t,v,f,l,self.url,query,ec,em,response) bci.ServerError: 302 (File: Unknown Line: Unknown) 302 Moved Temporarily for http://localhost:8080/manage_addFile ==================== Any idea what's happening? --Damon