[Tutor] Question about cgi module

2007-04-20 Thread Mike Hansen
Part of the web app that I'm writing will allow users to upload small
images to be stored in a database. Is there a way to limit how big of a
file that the user can upload? Is there some cgi setting that would
prevent a user from upload a huge file, or stop at a certain size and
error? 

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Question about cgi module

2007-04-20 Thread Andreas Kostyrka
* Mike Hansen <[EMAIL PROTECTED]> [070420 22:32]:
> Part of the web app that I'm writing will allow users to upload small
> images to be stored in a database. Is there a way to limit how big of a
> file that the user can upload? Is there some cgi setting that would
> prevent a user from upload a huge file, or stop at a certain size and
> error?

Not really. Perhaps.

You need envision the situtation:

http wise, the client assembles its request, and starts to send it to
the server. the http server is allowed to drop a http connection
anytime, and because file uploads are POSTs, the client should not
resent it without manual intervention by the user.

cgi wise, you need to check how your http server handles it.

Furthermore, you've got the little problem, that the standard cgi
module probably won't support that directly.

After having taken a view on the technical side, let's look at it from
the users perspective:

a) the error comes after the file was uploaded. Not much you can do
against that (Well, if you manage to interpret a Content-Length
header, you might abort the upload earlier, in theory).

b) aborting the request gives no sensible feedback to the user.

The typical solution for that is to use AJAX:

1.) get an unique id for the upload.
2.) post the file to an url containing the unique id.
3.) check the status of the upload via an AJAX method to give sensible
status messages, including errors.

(you need the unique id so that the AJAX calls can retrieve the status)

Andreas
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Python 2.4 or Python 2.5?

2007-04-20 Thread python
Im confused When i had python 2.4 all my scripts work correctly should i
reinstall python 2.4?  Or should I keep 2.5?  Where can I find information
on coding for python 2.5?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor