Package cherrypy :: Module _cpreqbody :: Class Part
[hide private]
[frames] | no frames]

Class Part

source code

object --+    
         |    
    Entity --+
             |
            Part

A MIME part entity, part of a multipart entity.

Nested Classes [hide private]

Inherited from Entity: part_class

Instance Methods [hide private]
 
__init__(self, fp, headers, boundary)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
read_lines_to_boundary(self, fp_out=None)
Read bytes from self.fp and return or write them to a file.
source code
 
default_proc(self)
Called if a more-specific processor is not found for the ``Content-Type``.
source code
 
read_into_file(self, fp_out=None)
Read the request body into fp_out (or make_file() if None).
source code

Inherited from Entity: __iter__, __next__, fullvalue, make_file, next, process, read, readline, readlines

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]
 
from_fp(cls, fp, boundary) source code
 
read_headers(cls, fp) source code
Class Variables [hide private]
  attempt_charsets = ['us-ascii', 'utf-8']
A list of strings, each of which should be a known encoding.
  boundary = None
The MIME multipart boundary.
  default_content_type = 'text/plain'
This defines a default ``Content-Type`` to use if no Content-Type header is given.
  maxrambytes = 1000
The threshold of bytes after which point the ``Part`` will store its data in a file (generated by :func:`make_file<cherrypy._cprequest.Entity.make_file>`) instead of a string.

Inherited from Entity: charset, content_type, filename, fp, headers, length, name, params, parts, processors

Properties [hide private]

Inherited from Entity: type

Inherited from object: __class__

Method Details [hide private]

__init__(self, fp, headers, boundary)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

read_lines_to_boundary(self, fp_out=None)

source code 

Read bytes from self.fp and return or write them to a file.

If the 'fp_out' argument is None (the default), all bytes read are returned in a single byte string.

If the 'fp_out' argument is not None, it must be a file-like object that supports the 'write' method; all bytes read will be written to the fp, and that fp is returned.

default_proc(self)

source code 

Called if a more-specific processor is not found for the ``Content-Type``.

Overrides: Entity.default_proc

read_into_file(self, fp_out=None)

source code 

Read the request body into fp_out (or make_file() if None).

Return fp_out.

Overrides: Entity.read_into_file

Class Variable Details [hide private]

attempt_charsets

A list of strings, each of which should be a known encoding.

When the Content-Type of the request body warrants it, each of the given encodings will be tried in order. The first one to successfully decode the entity without raising an error is stored as :attr:`entity.charset<cherrypy._cpreqbody.Entity.charset>`. This defaults to ``['utf-8']`` (plus 'ISO-8859-1' for "text/\*" types, as required by `HTTP/1.1 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7.1>`_), but ``['us-ascii', 'utf-8']`` for multipart parts.

Value:
['us-ascii', 'utf-8']

default_content_type

This defines a default ``Content-Type`` to use if no Content-Type header is given. The empty string is used for RequestBody, which results in the request body not being read or parsed at all. This is by design; a missing ``Content-Type`` header in the HTTP request entity is an error at best, and a security hole at worst. For multipart parts, however (this class), the MIME spec declares that a part with no Content-Type defaults to "text/plain".

Value:
'text/plain'

maxrambytes

The threshold of bytes after which point the ``Part`` will store its data in a file (generated by :func:`make_file<cherrypy._cprequest.Entity.make_file>`) instead of a string. Defaults to 1000, just like the :mod:`cgi` module in Python's standard library.

Value:
1000