Back to index

plone3  3.1.7
Classes | Functions | Variables
MimetypesRegistry.mime_types.smi_mimetypes Namespace Reference

Classes

class  SharedMimeInfoHandler

Functions

def readSMIFile
def initialize

Variables

tuple DIR = os.path.dirname(__file__)
string SMI_NAME = "freedesktop.org.xml"
tuple SMI_FILE = os.path.join(DIR, SMI_NAME)
tuple mimetypes = readSMIFile(SMI_FILE)

Function Documentation

Definition at line 67 of file smi_mimetypes.py.

00067 
00068 def initialize(registry):
00069     global mimetypes
00070     from Products.MimetypesRegistry.MimeTypeItem import MimeTypeItem
00071     from Products.MimetypesRegistry.common import MimeTypeException
00072     # Find things that are not in the specially registered mimetypes
00073     # and add them using some default policy, none of these will impl
00074     # iclassifier
00075     for res in mimetypes:
00076         mt = str(res['type'])
00077         mts = (mt,) + tuple(res['aliases'])
00078 
00079         # check the mime type
00080         try:
00081             mto =  registry.lookup(mt)
00082         except MimeTypeException:
00083             # malformed MIME type
00084             continue
00085 
00086         name = str(res['comments'].get(u'en', mt))
00087 
00088         # build a list of globs
00089         globs = []
00090         for glob in res['globs']:
00091             if registry.lookupGlob(glob):
00092                 continue
00093             else:
00094                 globs.append(glob)
00095 
00096         if mto:
00097             mto = mto[0]
00098             for glob in globs:
00099                 if not glob in mto.globs:
00100                     mto.globs = list(mto.globs) + [glob]
00101                     registry.register_glob(glob, mto)
00102             for mt in mts:
00103                 if not mt in mto.mimetypes:
00104                     mto.mimetypes = list(mto.mimetypes) + [mt]
00105                     registry.register_mimetype(mt, mto)
00106         else:
00107             isBin = mt.split('/', 1)[0] != "text"
00108             mti = MimeTypeItem(name, mimetypes=mts,
00109                                binary=isBin,
00110                                globs=globs)
00111             registry.register(mti)

Here is the call graph for this function:

Reads a shared mime info XML file

Definition at line 58 of file smi_mimetypes.py.

00058 
00059 def readSMIFile(infofile):
00060     """Reads a shared mime info XML file
00061     """
00062     handler = SharedMimeInfoHandler()
00063     parse(infofile, handler)
00064     return handler.mimes

Here is the call graph for this function:


Variable Documentation

tuple MimetypesRegistry.mime_types.smi_mimetypes.DIR = os.path.dirname(__file__)

Definition at line 5 of file smi_mimetypes.py.

Definition at line 65 of file smi_mimetypes.py.

Definition at line 7 of file smi_mimetypes.py.

Definition at line 6 of file smi_mimetypes.py.