Ticket #9404: flesh_out_uploaded_file.diff

File flesh_out_uploaded_file.diff, 4.4 KB (added by Todd O'Bryan, 16 years ago)
  • django/core/files/uploadedfile.py

     
    8484    # Most methods on this object get proxied to NamedTemporaryFile.
    8585    # We can't directly subclass because NamedTemporaryFile is actually a
    8686    # factory function
    87     def read(self, *args):          return self._file.read(*args)
    88     def seek(self, *args):          return self._file.seek(*args)
    89     def write(self, s):             return self._file.write(s)
    90     def tell(self, *args):          return self._file.tell(*args)
    91     def __iter__(self):             return iter(self._file)
    92     def readlines(self, size=None): return self._file.readlines(size)
    93     def xreadlines(self):           return self._file.xreadlines()
    9487    def close(self):
    9588        try:
    9689            return self._file.close()
     
    10295                return
    10396            else:
    10497                raise e
     98    def flush(self):                return self._file.flush()
     99    def fileno(self):               return self._file.fileno()
     100    def isatty(self):               return self._file.isatty()
     101    def next(self):                 return self._file.next()
     102    def __iter__(self):             return iter(self._file)
     103    def read(self, *args):          return self._file.read(*args)
     104    def readline(self, *args):      return self._file.readline(*args)
     105    def readlines(self, *args):     return self._file.readlines(*args)
     106    def xreadlines(self):           return self._file.xreadlines()
     107    def seek(self, *args):          return self._file.seek(*args)
     108    def tell(self, *args):          return self._file.tell(*args)
     109    def truncate(self, *args):      return self._file.truncate(*args)
     110    def write(self, *args):         return self._file.write(*args)
     111    def writelines(self, *args):    return self._file.writelines(*args)
     112    closed = property(lambda me : getattr(me._file, 'closed'))
     113    encoding = property(lambda me : getattr(me._file, 'encoding'))
     114    errors = property(lambda me : getattr(me._file, 'errors'),
     115                      lambda me, val : setattr(me._file, 'errors', val))
     116    mode = property(lambda me : getattr(me._file, 'mode'))
     117    newlines = property(lambda me : getattr(me._file, 'newlines'))
     118    softspace = property(lambda me : getattr(me._file, 'softspace'),
     119                         lambda me, val : setattr(me._file, 'softspace', val))
    105120
    106121class InMemoryUploadedFile(UploadedFile):
    107122    """
     
    125140        return False
    126141
    127142    # proxy methods to StringIO
    128     def read(self, *args): return self._file.read(*args)
    129     def seek(self, *args): return self._file.seek(*args)
    130     def tell(self, *args): return self._file.tell(*args)
    131     def close(self):       return self._file.close()
     143    def close(self):                return self._file.close()
     144    def flush(self):                return self._file.flush()
     145    def fileno(self):               return self._file.fileno()
     146    def isatty(self):               return self._file.isatty()
     147    def next(self):                 return self._file.next()
     148    def __iter__(self):             return iter(self._file)
     149    def read(self, *args):          return self._file.read(*args)
     150    def readline(self, *args):      return self._file.readline(*args)
     151    def readlines(self, *args):     return self._file.readlines(*args)
     152    def xreadlines(self):           return self._file.xreadlines()
     153    def seek(self, *args):          return self._file.seek(*args)
     154    def tell(self, *args):          return self._file.tell(*args)
     155    def truncate(self, *args):      return self._file.truncate(*args)
     156    def write(self, *args):         return self._file.write(*args)
     157    def writelines(self, *args):    return self._file.writelines(*args)
     158    closed = property(lambda me : getattr(me._file, 'closed'))
     159    encoding = property(lambda me : getattr(me._file, 'encoding'))
     160    errors = property(lambda me : getattr(me._file, 'errors'),
     161                      lambda me, val : setattr(me._file, 'errors', val))
     162    mode = property(lambda me : getattr(me._file, 'mode'))
     163    newlines = property(lambda me : getattr(me._file, 'newlines'))
     164    softspace = property(lambda me : getattr(me._file, 'softspace'),
     165                         lambda me, val : setattr(me._file, 'softspace', val))
    132166
    133167class SimpleUploadedFile(InMemoryUploadedFile):
    134168    """
Back to Top