[Web-SIG] Returned application object and fileno.

Alan Kennedy py-web-sig at xhaus.com
Tue Aug 31 21:01:24 CEST 2004


Dear Sig,

Currently the spec says that the application can return an object which 
has a callable fileno attribute, which can return a file descriptor.

The current wording is "If the returned iterable has a fileno attribute, 
the server may assume that this is a fileno() method returning an 
operating system file descriptor, and that it is allowed to read 
directly from that descriptor up to the end of the file, and/or use any 
appropriate operating system facilities (e.g. the sendfile() system 
call) to transmit the file's contents. If the server does this, it must 
begin transmission with the file's current position, and end at the end 
of the file."

Problem is that jython doesn't support file descriptors, or the fileno() 
method. If you invoke fileno() on an org.python.core.PyFile, you get an 
Py.IOError("fileno() is not supported in jpython") exception.

Is there any more portable way that we can detect the application 
returning a file(-like object)?

Maybe checking type(app_object) == types.FileType?

Or checking if the object has a read() method?

I can imagine that a similar problem may arise later with IronPython on 
the MS CLR, which I believe doesn't use file descriptors either: like 
java, it is stream based.

Regards,

Alan.


More information about the Web-SIG mailing list