> Betreff: RE: [Zope-dev] FileUpload and blob on Windows
> Hi Mark,
> Mark Hammond-3 wrote:
> > 
> > [...]
> >> unless we use some non-portable win32 code to allow writing and 
> >> reading to the same file simultaneously.
> > 
> > I'm not sure exactly what you mean by "simultaneously", but 
> assuming 
> > you just need the ability to read and write to a file, you already 
> > can.  Does this behaviour help?
> > 
> >>>> import tempfile
> >>>> f = tempfile.NamedTemporaryFile()
> >>>> f.write("hello")
> >>>> f.seek(0,0)
> >>>> f.read()
> > 'hello'

Why are you using a NamedTemporaryFile? If I'm right the 
goal is to store the file stream from the upload directly
in this file and copy this file over to the real directory 
This means you can cut down the amount of read and write file data, right?

Why not use a own file class like:

class TMPFile(file):
    """Temorary file.
    This temporary file can remove a file in request.close() form the file

    def release(self):
        """Release the object in the requests (_held) list."""
        if self.name is not None and os.path.exists(self.name):

You can move such a file with shutil.move(self.tmpPath, targetPath).

I implemented such a file upload accelerator. With this beast I was able
to upload a ubuntu vmware image with > 950 MB in about 75 seconds to Zope3.
And this with a memory usage below 50 MB. It really rocks.

Note; I implemented this on windows and it works well.

Roger Ineichen

Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to