On Apr 30, 11:44 am, vv2 <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> I just noticed latest changeset in django-trunk (http://
> code.djangoproject.com/changeset/7510) and I started wondering if it
> is possible to pass file contents to output without actually storing
> it in memory.
>
> So, the question is:
> Is there anything like PHP's fpassthru() function (http://uk3.php.net/
> fpassthru) possible in Django? There is a lot of framework layers to
> get through, so I suppose it's not really possible?

The Python WSGI specification supports an optional extension
wsgi.file_wrapper. See:

  
http://www.python.org/dev/peps/pep-0333/#optional-platform-specific-file-handling

A WSGI adapter for a server may implement this if it wishes, although
not many do.

One which does is mod_wsgi for Apache.

The result is that the web application can pass an open file object
and in case where it is a wrapper for a C level FILE object, mod_wsgi
is able to use the associated file descriptor and get lower levels of
Apache to effectively send anything accessible through the file
descriptor. Apache will use memory mapping or sendfile() calls where
it can to send the contents of the file, thereby avoiding having to
actually copy the contents into memory.

Although Django can be hosted on WSGI, I am not sure if it makes use
of this if it is available. I know it is mentioned in django/core/
servers/basehttp.py, and that there are are means of specifying
platform specific ways of sending files, but does it actually get used
if it is available. That is a question I'd like to know as well
because if Django uses wsgi.file_wrapper automatically already, I
could advertise it as another benefit of mod_wsgi. :-)

Graham
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to