Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.support.werkzeug.utils.FileStorage Class Reference

List of all members.

Public Member Functions

def __init__
def save
def close
def __nonzero__
def __getattr__
def __iter__
def __repr__

Public Attributes

 name
 stream
 filename
 content_type
 content_length

Detailed Description

The :class:`FileStorage` class is a thin wrapper over incoming files.
It is used by the request object to represent uploaded files.  All the
attributes of the wrapper stream are proxied by the file storage so
it's possible to do ``storage.read()`` instead of the long form
``storage.stream.read()``.

Definition at line 36 of file utils.py.


Constructor & Destructor Documentation

def MoinMoin.support.werkzeug.utils.FileStorage.__init__ (   self,
  stream = None,
  filename = None,
  name = None,
  content_type = 'application/octet-stream',
  content_length = -1 
)

Definition at line 45 of file utils.py.

00045 
00046                  content_type='application/octet-stream', content_length=-1):
00047         self.name = name
00048         self.stream = stream or _empty_stream
00049         self.filename = filename or getattr(stream, 'name', None)
00050         self.content_type = content_type
00051         self.content_length = content_length


Member Function Documentation

Definition at line 87 of file utils.py.

00087 
00088     def __getattr__(self, name):
00089         return getattr(self.stream, name)

Definition at line 90 of file utils.py.

00090 
00091     def __iter__(self):
00092         return iter(self.readline, '')

Here is the call graph for this function:

Definition at line 84 of file utils.py.

00084 
00085     def __nonzero__(self):
00086         return bool(self.filename)

Definition at line 93 of file utils.py.

00093 
00094     def __repr__(self):
00095         return '<%s: %r (%r)>' % (
00096             self.__class__.__name__,
00097             self.filename,
00098             self.content_type
00099         )
00100 

Close the underlaying file if possible.

Definition at line 77 of file utils.py.

00077 
00078     def close(self):
00079         """Close the underlaying file if possible."""
00080         try:
00081             self.stream.close()
00082         except:
00083             pass

Here is the caller graph for this function:

def MoinMoin.support.werkzeug.utils.FileStorage.save (   self,
  dst,
  buffer_size = 16384 
)
Save the file to a destination path or file object.  If the
destination is a file object you have to close it yourself after the
call.  The buffer size is the number of bytes held in memory during
the copy process.  It defaults to 16KB.

For secure file saving also have a look at :func:`secure_filename`.

:param dst: a filename or open file object the uploaded file
    is saved to.
:param buffer_size: the size of the buffer.  This works the same as
            the `length` parameter of
            :func:`shutil.copyfileobj`.

Definition at line 52 of file utils.py.

00052 
00053     def save(self, dst, buffer_size=16384):
00054         """Save the file to a destination path or file object.  If the
00055         destination is a file object you have to close it yourself after the
00056         call.  The buffer size is the number of bytes held in memory during
00057         the copy process.  It defaults to 16KB.
00058 
00059         For secure file saving also have a look at :func:`secure_filename`.
00060 
00061         :param dst: a filename or open file object the uploaded file
00062                     is saved to.
00063         :param buffer_size: the size of the buffer.  This works the same as
00064                             the `length` parameter of
00065                             :func:`shutil.copyfileobj`.
00066         """
00067         from shutil import copyfileobj
00068         close_dst = False
00069         if isinstance(dst, basestring):
00070             dst = file(dst, 'wb')
00071             close_dst = True
00072         try:
00073             copyfileobj(self.stream, dst, buffer_size)
00074         finally:
00075             if close_dst:
00076                 dst.close()

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 50 of file utils.py.

Definition at line 49 of file utils.py.

Definition at line 48 of file utils.py.

Definition at line 46 of file utils.py.

Definition at line 47 of file utils.py.


The documentation for this class was generated from the following file: