gridfs::grid_file::GridIn Class Reference

List of all members.

Public Member Functions

def __enter__
def __exit__
def __getattr__
def __init__
def __setattr__
def close
def closed
def write
def writelines

Static Public Attributes

tuple chunk_size
tuple content_type = _create_property("contentType", "Mime-type for this file.")
tuple filename = _create_property("filename", "Name of this file.")
tuple length
tuple md5
tuple upload_date

Private Member Functions

def __flush
def __flush_buffer
def __flush_data

Private Attributes


Static Private Attributes

tuple _id

Detailed Description

Class to write data to GridFS.

Definition at line 78 of file

Member Function Documentation

def gridfs::grid_file::GridIn::__enter__ (   self  ) 
Support for the context manager protocol.

Definition at line 293 of file

def gridfs::grid_file::GridIn::__exit__ (   self,
Support for the context manager protocol.

Close the file and allow exceptions to propogate.

Definition at line 298 of file

def gridfs::grid_file::GridIn::__flush (   self  )  [private]
Flush the file to the database.

Definition at line 196 of file

def gridfs::grid_file::GridIn::__flush_buffer (   self  )  [private]
Flush the buffer contents out to a chunk.

Definition at line 189 of file

def gridfs::grid_file::GridIn::__flush_data (   self,
) [private]
Flush `data` to a chunk.

Definition at line 174 of file

def gridfs::grid_file::GridIn::__getattr__ (   self,

Definition at line 163 of file

def gridfs::grid_file::GridIn::__init__ (   self,
Write a file to GridFS

Application developers should generally not need to
instantiate this class directly - instead see the methods
provided by :class:`~gridfs.GridFS`.

Raises :class:`TypeError` if `root_collection` is not an
instance of :class:`~pymongo.collection.Collection`.

Any of the file level options specified in the `GridFS Spec
<>`_ may be passed as
keyword arguments. Any additional keyword arguments will be
set as additional fields on the file document. Valid keyword
arguments include:

  - ``"_id"``: unique ID for this file (default:
    :class:`~bson.objectid.ObjectId`) - this ``"_id"`` must
    not have already been used for another file

  - ``"filename"``: human name for the file

  - ``"contentType"`` or ``"content_type"``: valid mime-type
    for the file

  - ``"chunkSize"`` or ``"chunk_size"``: size of each of the
    chunks, in bytes (default: 256 kb)

  - ``"encoding"``: encoding used for this file - any
    :class:`unicode` that is written to the file will be
    converted to a :class:`str` with this encoding

  - `root_collection`: root collection to write to
  - `**kwargs` (optional): file level options (see above)

Definition at line 81 of file

def gridfs::grid_file::GridIn::__setattr__ (   self,

Definition at line 168 of file

def gridfs::grid_file::GridIn::close (   self  ) 
Flush the file and close it.

A closed file cannot be written any more. Calling
:meth:`close` more than once is allowed.

Definition at line 213 of file

def gridfs::grid_file::GridIn::closed (   self  ) 
Is this file closed?

Definition at line 143 of file

def gridfs::grid_file::GridIn::write (   self,
Write data to the file. There is no return value.

`data` can be either a string of bytes or a file-like object
(implementing :meth:`read`). If the file has an
:attr:`encoding` attribute, `data` can also be a
:class:`unicode` instance, which will be encoded as
:attr:`encoding` before being written.

Due to buffering, the data may not actually be written to the
database until the :meth:`close` method is called. Raises
:class:`ValueError` if this file is already closed. Raises
:class:`TypeError` if `data` is not an instance of
:class:`str`, a file-like object, or an instance of
:class:`unicode` (only allowed if the file has an
:attr:`encoding` attribute).

  - `data`: string of bytes or file-like object to be written
    to the file

.. versionadded:: 1.9
   The ability to write :class:`unicode`, if the file has an
   :attr:`encoding` attribute.

Definition at line 223 of file

def gridfs::grid_file::GridIn::writelines (   self,
Write a sequence of strings to the file.

Does not add seperators.

Definition at line 285 of file

Member Data Documentation

Definition at line 194 of file

Definition at line 221 of file

tuple gridfs::grid_file::GridIn::_id [static, private]
Initial value:
_create_property("_id", "The ``'_id'`` value for this file.",

Definition at line 148 of file

Initial value:
_create_property("chunkSize", "Chunk size for this file.",

Definition at line 154 of file

tuple gridfs::grid_file::GridIn::content_type = _create_property("contentType", "Mime-type for this file.") [static]

Definition at line 151 of file

tuple gridfs::grid_file::GridIn::filename = _create_property("filename", "Name of this file.") [static]

Definition at line 150 of file

Initial value:
_create_property("length", "Length (in bytes) of this file.",

Definition at line 152 of file

Initial value:
_create_property("md5", "MD5 of the contents of this file "
                            "(generated on the server).",

Definition at line 159 of file

Initial value:
                                    "Date that this file was uploaded.",

Definition at line 156 of file

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines

Author(s): Bhaskara Marthi
autogenerated on Fri Jan 11 10:09:06 2013