FYI: Possible Solution to File Upload with Progress Bar

2 views
Skip to first unread message

Ian Charnas

unread,
Nov 11, 2006, 11:56:18 PM11/11/06
to TurboGears
I'm developing a Web 2.0 CMS for Turbogears right now and I'm working
on a file uploader with a progress bar. I'm sure I'm not the only one
searching for a good solution to this.

The difficulty is that your turbogears controller isn't getting called
until *after* the file is already downloaded by CherryPy, so there's no
way to monitor the file progress. Or is there? James (aka tweekgeek)
has created a filter in CherryPy that adds additional functionality to
CherryPy's FieldStorage class (the class that handles file uploads).
Not only does his filter support monitoring the file progress, it also
adds some much-needed security that allows you to limit the memory,
disk space, and threads used by the file uploading processes. And as a
bonus, it doesn't even use an IFrame like most popular approaches
(dojo, yahoo ui, etc)! I'll have to test his solution in a full
browser regimen (using browsercam) before I go with this, but have a
look:

Take a look at his screenshot of the progress bar:
http://www.kepty.com/static/screenshot.jpg

or download his code, which includes a filter and a sample app:
http://www.kepty.com/static/uploadfilter-1.0.tar.gz

Fumanchu (the CherryPy maintainer) suggested he will integrate this (or
something similar) into CherryPy 3 (as a CherryPy 3 'hook', instead of
the to-be-depricated filters).

I can work this into TurboGears as a patch and a new widget, but I fear
it would be rejected because a) it's all going to have to change with
the release of cherrypy 3, and b) I'm going to have to add a
'get_file_upload_statistics' method (or something similar) to the
RootController class, which there is no precedent for. Could someone
who is committing code comment on this and give me some feedback? I'd
love to code this up for public use!

gasolin

unread,
Nov 12, 2006, 1:38:44 AM11/12/06
to TurboGears
Ian:

The time-saver way is to add a new tickst in trac (if it works again)
and append your code there.

Or, if you had time, try to write an article on docs.turbogears.org to
help people who meet the same issue.(I'd recommend you to try this way)

http://docs.turbogears.org/1.0/RoughDocs

--
Fred

Jorge Godoy

unread,
Nov 12, 2006, 7:17:44 AM11/12/06
to turbo...@googlegroups.com
"Ian Charnas" <i...@case.edu> writes:

> I can work this into TurboGears as a patch and a new widget, but I fear
> it would be rejected because a) it's all going to have to change with
> the release of cherrypy 3, and b) I'm going to have to add a
> 'get_file_upload_statistics' method (or something similar) to the
> RootController class, which there is no precedent for. Could someone
> who is committing code comment on this and give me some feedback? I'd
> love to code this up for public use!

Can't there be another kind of communication? I believe that this would be
much better if it fitted the new idea that Alberto had for widgets that made
them "framework independent". So, if you're willing to use CP + <something>
you wouldn't have TG's RootController there.

I haven't thought of how to signal to the app how much has been done, but it
should probably be using events and some kind of listener for those events.

--
Jorge Godoy <jgo...@gmail.com>

Ian Charnas

unread,
Dec 20, 2006, 6:39:24 PM12/20/06
to TurboGears
For those searching the TG archives, there's an update on this issue:
http://groups-beta.google.com/group/turbogears/browse_thread/thread/36a7b593250b20e0

Reply all
Reply to author
Forward
0 new messages