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!
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
> 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>