[Zope] Using urllib2 to access Zope URLs

Damon Butler damon@hddesign.com
28 May 2003 15:45:09 -0500


On Tue, 2003-05-27 at 15:54, Dieter Maurer wrote:
>  > 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
>  > ====================
>
> You could ignore this "error".
> 
> The HTTP spec says, that response codes 2xx are good and response
> codes 3xx mean, the request is not complete.
> Apparently, "Client" interprets the HTTP spec very tightly.
> Any response code other than 2xx results in an exception.
> 
> For most automisation tasks, response code 302 can be treated
> as "ok", however.

That's good to know. Thanks!

> ....  hangs for large files ....
> 
> I analysed such a problem recently. It turned out that
> the script did not hang but that the transfer took very
> long. In my case, the transfer of a 60 MB file took 11 minutes (locally
> on one host). During this time, the IOWait of the
> processor was between 50 and 90 %.
> I was really astonished about this low bandwidth.
> I do not know what subcomponent was responsible but I am
> sure it was not ZPublisher.Client (it just builds a huge string
> and transfers it via the socket in a single "send"; this is very
> memory intensive but should not cause high IOWait over minutes
> (reading the file took 20 s)).

Well, that's no good.
There is a happy ending, however. I managed to find a solution to my
problem with a recipe from ZopeLabs:

http://www.zopelabs.com/cookbook/1029932854

It uses urllib instead of urllib2, and with a bit of refactoring, I was
able to make a script that uploaded batches to arbitrary urls from the
command line. Just what I wanted.

Thanks for your help!
--Damon