summaryrefslogtreecommitdiff
path: root/django/core/files/utils.py
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2009-05-08 15:08:09 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2009-05-08 15:08:09 +0000
commit68a890e79f660484d05482902663b6168f0bd71e (patch)
tree201e3380e461d0d7bdcfeb42a0994b703fca349e /django/core/files/utils.py
parent2af75b485db15a8494b040aa04337c052b896cca (diff)
downloaddjango-68a890e79f660484d05482902663b6168f0bd71e.tar.gz
Fixed #7712, #9404, #10249, #10300: a light refactor and cleanup of file storage and the `File` object. Thanks to Armin Ronacher and Alex Gaynor.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10717 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/core/files/utils.py')
-rw-r--r--django/core/files/utils.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/django/core/files/utils.py b/django/core/files/utils.py
new file mode 100644
index 0000000000..8cc212fe1f
--- /dev/null
+++ b/django/core/files/utils.py
@@ -0,0 +1,29 @@
+class FileProxyMixin(object):
+ """
+ A mixin class used to forward file methods to an underlaying file
+ object. The internal file object has to be called "file"::
+
+ class FileProxy(FileProxyMixin):
+ def __init__(self, file):
+ self.file = file
+ """
+
+ encoding = property(lambda self: self.file.encoding)
+ fileno = property(lambda self: self.file.fileno)
+ flush = property(lambda self: self.file.flush)
+ isatty = property(lambda self: self.file.isatty)
+ newlines = property(lambda self: self.file.newlines)
+ read = property(lambda self: self.file.read)
+ readinto = property(lambda self: self.file.readinto)
+ readline = property(lambda self: self.file.readline)
+ readlines = property(lambda self: self.file.readlines)
+ seek = property(lambda self: self.file.seek)
+ softspace = property(lambda self: self.file.softspace)
+ tell = property(lambda self: self.file.tell)
+ truncate = property(lambda self: self.file.truncate)
+ write = property(lambda self: self.file.write)
+ writelines = property(lambda self: self.file.writelines)
+ xreadlines = property(lambda self: self.file.xreadlines)
+
+ def __iter__(self):
+ return iter(self.file)