Apache Mod-Python - Re: mod_python 3.2.3b available for testing

This is Interesting: Free IT Magazines  
Home > Archive > Apache Mod-Python > October 2005 > Re: mod_python 3.2.3b available for testing





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: mod_python 3.2.3b available for testing
Nick

2005-10-25, 5:46 pm

Well, here's another alternative: provide some other attribute to Field,
such as is_file, to determine whether or not the Field is an actual file
upload or something else. Because as implemented, the file attribute will
always return a file-type object.

Nick

Nick wrote:
> Jorey Bump wrote:
>
>
>
> At a minimum, the documentation:
>
> "This is a file object. For file uploads it points to a temporary file.
> For simple values, it is a StringIO object, so you can read simple
> string values via this attribute instead of using the value attribute
> as well."
>
> As I stated, it just may be enough to document here that it's a file
> -or- a file-type object. That's what the Python documentation for
> tempfile.TemporaryFile states, so maybe calling it a "bug" is wrong.
> But it's equally simple to return the actual file object, and in my
> opinion more convenient for programmers to do isinstance(field.file,
> file) to see if you have an uploaded file vs. some other kind of value.
> I don't know enough about Windows though to know what will happen if you
> garbage collect the tempfile._TemporaryFileWrapper object but keeping a
> reference to the file.
>
> It's unfortunate that it's not possible to subclass a builtin type and
> overload its methods (that I know of).
>
> Nick



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com