API Reference¶
zope.mimetype.interfaces¶
interfaces for mimetype package
-
interface
ICharset[source]¶ Information about a charset
-
encoding¶ Encoding
The id of the encoding used for this charset.
-
name¶ Name
The charset name. This is what is used for the ‘charset’ parameter in content-type headers.
-
-
interface
ICodec[source]¶ Information about a codec.
-
name¶ Name
The name of the Python codec.
-
title¶ Title
The human-readable name of this codec.
-
writer(stream, errors='strict')¶ Construct a StramWriter object for this codec.
-
decode(input, errors='strict')¶ Decodes the input and returns a tuple (output, length consumed).
-
reader(stream, errors='strict')¶ Construct a StreamReader object for this codec.
-
encode(input, errors='strict')¶ Encodes the input and returns a tuple (output, length consumed).
-
-
interface
ICodecPreferredCharset[source]¶ Marker interface for locating the preferred charset for a Codec.
-
interface
ICodecTerm[source]¶ Extends:
zope.schema.interfaces.ITitledTokenizedTermExtended term that describes a content type interface.
-
preferredCharset¶ Preferred Charset
Charset that should be used to represent the codec
-
-
interface
IContentInfo[source]¶ Interface describing effective MIME type information.
When using MIME data from an object, an application should adapt the object to this interface to determine how it should be interpreted. This may be different from the information
-
getCodec()¶ Return an
ICodecthat should be used to decode/encode data.This should return
Noneif the object’sIContentTypeinterface does not derive fromIContentTypeEncoded.If the content type is encoded and no encoding information is available in the
effectiveParameters, this method may return None, or may provide a codec based on application policy.If
effectiveParametersindicates a specific charset, and no codec is registered to support that charset,ValueErrorwill be raised.
-
contentType¶ Content type
The value of the Content-Type header, including both the MIME type and any parameters.
-
effectiveMimeType¶ Effective MIME type
MIME type that should be reported when downloading the document this
IContentInfoobject is for.
-
decode(s)¶ Return the decoding of
sbased on the effective encoding.The effective encoding is determined by the return from the
getCodec()method.ValueErroris raised if no codec can be found for the effective charset.
-
effectiveParameters¶ Effective parameters
Content-Type parameters that should be reported when downloading the document this
IContentInfoobject is for.
-
-
interface
IContentType[source]¶ Marker interface for objects that represent content with a MIME type.
-
interface
IContentTypeAware[source]¶ Interface for MIME content type information.
Objects that can provide content type information about the data they contain, such as file objects, should be adaptable to this interface.
-
mimeType¶ Mime Type
The mime type explicitly specified for the object that this MIME information describes, if any. May be None, or an ASCII MIME type string of the form major/minor.
-
parameters¶ Mime Type Parameters
The MIME type parameters (such as charset).
-
-
interface
IContentTypeChangedEvent[source]¶ Extends:
zope.interface.interfaces.IObjectEventThe content type for an object has changed.
All changes of the
IContentTypeInterfacefor an object are reported by this event, including the setting of an initial content type and the removal of the content type interface.This event should only be used if the content type actually changes.
-
interface
IContentTypeEncoded[source]¶ Extends:
zope.mimetype.interfaces.IContentTypeMarker interface for content types that care about encoding.
This does not imply that encoding information is known for a specific object.
Content types that derive from
IContentTypeEncodedsupport a content type parameter named ‘charset’, and that parameter is used to control encoding and decoding of the text.For example, interfaces for text/* content types all derive from this base interface.
-
interface
IContentTypeInterface[source]¶ Interface that describes a logical mime type.
Interfaces that provide this interfaces are content-type interfaces.
Most MIME types are described by the IANA MIME-type registry (http://www.iana.org/assignments/media-types/).
-
interface
IContentTypeSource[source]¶ Extends:
zope.schema.interfaces.ISource,zope.schema.interfaces.IIterableSourceSource for content types.
-
interface
IContentTypeTerm[source]¶ Extends:
zope.schema.interfaces.ITitledTokenizedTermExtended term that describes a content type interface.
-
mimeTypes¶ MIME types
List of MIME types represented by this interface; the first should be considered the preferred MIME type.
-
extensions¶ Extensions
Filename extensions commonly associated with this type of file.
-
zope.mimetype.codec¶
zope.mimetype.contentinfo¶
Default IContentInfo implementation.
zope.mimetype.event¶
Implementation of and support for the IContentTypeChangedEvent.
zope.mimetype.i18n¶
I18N support for the zope.mime package.
This defines a MessageFactory for the I18N domain for the
zope.mimetype package. This is normally used with this import:
from i18n import MessageFactory as _
The factory is then used normally. Two examples:
text = _('some internationalized text')
text = _('helpful-descriptive-message-id', 'default text')
zope.mimetype.mtypes¶
Mime-Types management
zope.mimetype.source¶
Sources for IContentTypeInterface providers and codecs.
-
class
CodecSource[source]¶ Bases:
zope.mimetype.source.UtilitySourceSource of ICodec providers.
-
class
CodecTerms(source, request)[source]¶ Bases:
zope.mimetype.source.TermsUtility to provide terms for codecs.
-
class
ContentTypeSource[source]¶ Bases:
zope.mimetype.source.UtilitySourceSource of IContentTypeInterface providers.
-
class
ContentTypeTerms(source, request)[source]¶ Bases:
zope.mimetype.source.TermsUtility to provide terms for content type interfaces.
zope.mimetype.typegetter¶
-
charsetGetter(name=None, data=None, content_type=None)[source]¶ Default implementation of
zope.mimetype.interfaces.ICharsetGetter.
-
mimeTypeGetter(name=None, data=None, content_type=None)[source]¶ A minimal extractor that never attempts to guess.
-
mimeTypeGuesser(name=None, data=None, content_type=None)[source]¶ An extractor that tries to guess the content type based on the name and data if the input contains no content type information.
-
smartMimeTypeGuesser(name=None, data=None, content_type=None)[source]¶ An extractor that checks the content for a variety of constructs to try and refine the results of the
mimeTypeGuesser(). This is able to do things like check for XHTML that’s labelled as HTML in upload data.
zope.mimetype.utils¶
Utility helpers
zope.mimetype.widget¶
Widget that provides translation and sorting for an IIterableSource.
This widget translates the term titles and presents those in sorted order.
Properly, this should call on a language-specific collation routine, but we don’t currently have those. Also, it would need to deal with a partially-translated list of titles when translations are only available for some of the titles.
The implementation ignores these issues for now.
zope.mimetype.zcml¶
-
interface
ICharsetDirective[source]¶ Defines a charset in a codec.
Example:
<charset name="iso8859-1" preferred="True" /> <charset name="latin1" />
-
preferred¶ Preferred
Is this is the preferred charset for the encoding.
-
name¶ Name
The name of the Python codec.
-