Back to index

plone3  3.1.7
interfaces.py
Go to the documentation of this file.
00001 from zope.interface import Interface as z3Interface
00002 from Interface import Interface
00003 
00004 class IMimetype(Interface):
00005     """Specification for dealing with mimetypes RFC-2046 style"""
00006 
00007 #     mimetypes = Attribute("List of mimetypes in the RFC-2046 format")
00008 #     extensions = Attribute("""List of extensions mapped to this
00009 #     mimetype w/o the leading .""")
00010 
00011 #     binary = Attribute("""Boolean indicating if the mimetype should be
00012 #     treated as binary (and not human readable)""")
00013 
00014     def name(self):
00015         """return the Human readable name of the mimetype"""
00016 
00017     def major(self):
00018         """ return the major part of the RFC-2046 name for this mime type """
00019 
00020     def minor(self):
00021         """ return the minor part of the RFC-2046 name for this mime type """
00022 
00023     def normalized(self):
00024         """ return the main RFC-2046 name for this mime type
00025 
00026         e.g. if this object has names ('text/restructured', 'text-x-rst')
00027         then self.normalized() will always return the first form.
00028         """
00029 
00030 class IClassifier(Interface):
00031     """Optional mixin interface for imimetype, code to test if the
00032     mimetype is present in data
00033     """
00034     def classify(data):
00035         """ boolean indicating if the data fits the mimetype"""
00036 
00037 
00038 class ISourceAdapter(Interface):
00039 
00040     def __call__(data, **kwargs):
00041         """convert data to unicode, may take optional kwargs to aid in
00042         conversion"""
00043 
00044 
00045 class IMimetypesRegistry(Interface):
00046 
00047     def classify(data, mimetype=None, filename=None):
00048         """return a content type for this data or None
00049         None should rarely be returned as application/octet can be
00050         used to represent most types
00051         """
00052 
00053     def lookup(mimetypestring):
00054         """Lookup for imimetypes object matching mimetypestring
00055 
00056         mimetypestring may have an empty minor part or containing a wildcard (*)
00057         mimetypestring may be an imimetype object (in this case it will be
00058         returned unchanged, else it should be a RFC-2046 name
00059 
00060         return a list of mimetypes objects associated with the RFC-2046 name
00061         return an empty list if no one is known.
00062         """
00063 
00064     def lookupExtension(filename):
00065         """ return the mimetypes object associated with the file's extension
00066         return None if it is not known.
00067 
00068         filename maybe a file name like 'content.txt' or an extension like 'rest'
00069         """
00070 
00071     def mimetypes():
00072         """return all defined mime types, each one implements at least imimetype
00073         """
00074 
00075     def list_mimetypes():
00076         """return all defined mime types, as string"""
00077 
00078 class IMimetypesRegistryTool(z3Interface):
00079     """Marker interface for the mimetypes_registry tool."""