[Zope] external method with import tarfile

Tino Wildenhain tino at wildenhain.de
Wed Jul 19 11:04:28 EDT 2006


Alan wrote:
> Hi there!
> 
> I managed to find the problem and the solution.
> 
> First, I've forgot to mention that in my script, oname is an uploaded file.
> I just inserted a f.close() and voilá!
> 
> def upload_external(self,file,REQUEST):
>   import os,tarfile
> ...
>   f=open(oname,"wb")
>   f.write(file.read())
>   f.close()
> ...
>   tar = tarfile.open(oname,"r:gz")
>   for itar in tar:
>   tar.extract(itar.name,jobdir)
>   return "Done"
> 

Err. why not

tar=tarfile.open(fileobj=file) ?
Why bother with potentially name clashing
files in filesystem?

Regards
Tino


More information about the Zope mailing list