[Grok-dev] File Upload with Tramline

Martijn Faassen faassen at startifact.com
Mon Jan 11 19:33:51 EST 2010


Hannes wrote:
> I've another concern. I played a little bit with Tramline and HurryFile.
> How do I get a upload widget? How do I handle the remote file transfer 
> from the client to the server?
> Is this all done automatically? The HurryFile sample code from PyPi has 
> some gaps... :-(

I agree that the example has gaps - it isn't a great example as it was 
primarily written for testing purposes..

For normal file uploads you could use hurry.file, setting the widget as 
a custom_widget to your form (find a form tutorial), but you could even 
just resort to a 'schema.File' field and everything should work. 
hurry.file just makes a few things a bit more convenient (like retaining 
the uploaded file when the form failed to validate instead of forcing a 

The difficulty is with storing large files in the ZODB. Tramline is one 
way around this (you can find tramline's INSTALL.txt here):


This makes use of Apache's upload and download facility but can be 
somewhat involved to set up.

Alternatively these days the ZODB is quite capable of storing large 
files as a "blob". Tramline can be avoided that way (even though the 
performance of tramline would probably be a bit higher for many uploads 
or downloads).

z3c.blobfile can be used to help storing large files in a convenient way.


An example of this can be found here (in an older grok application, and 
no UI bits are included as this is a web service):


(and imagecontainer.py. actually the use is only very minimal so perhaps 
not that instructive)

Once you get something figured out we'd be very happy to see a tutorial 
or howto appear on grok.zope.org by the way. :)



More information about the Grok-dev mailing list