--- /home/abourget/build/Intr/env/lib/python2.6/site-packages/paste/fileapp.py	2011-02-15 15:29:45.000000000 -0500
+++ fileapp.py	2011-02-15 23:46:28.842094999 -0500
@@ -30,6 +30,13 @@
 
         ``headers``     the headers to send /w the response
 
+        ``filelike``    whether the content is a file-like obj.
+
+        If you set ``filelike`` to True, the ``length`` attribute
+        will be checked first to know the length of the file. Also,
+        the ``seek()`` and ``read()`` methods will be used to
+        fetch the file contents.
+
         The remaining ``kwargs`` correspond to headers, where the
         underscore is replaced with a dash.  These values are only
         added to the headers if they are not already provided; thus,
@@ -57,10 +64,11 @@
     allowed_methods = ('GET', 'HEAD')
 
     def __init__(self, content, headers=None, allowed_methods=None,
-                 **kwargs):
+                 filelike=False, **kwargs):
         assert isinstance(headers, (type(None), list))
         self.expires = None
         self.content = None
+        self.filelike = filelike
         self.content_length = None
         self.last_modified = 0
         if allowed_methods is not None:
@@ -86,7 +94,10 @@
         else:
             self.last_modified = last_modified
         self.content = content
-        self.content_length = len(content)
+        if self.filelike and hasattr(content, 'length'):
+            self.content_length = content.length
+        else:
+            self.content_length = len(content)
         LAST_MODIFIED.update(self.headers, time=self.last_modified)
         return self
 
@@ -163,7 +174,11 @@
         else:
             start_response('206 Partial Content', headers)
         if self.content is not None:
-            return [self.content[lower:upper+1]]
+            if self.filelike:
+                self.content.seek(lower)
+                return [self.content.read(upper - lower + 1)]
+            else:
+                return [self.content[lower:upper+1]]
         return (lower, content_length)
 
 class FileApp(DataApp):
