Back to index

plone3  3.1.7
suppl_mimetypes.py
Go to the documentation of this file.
00001 from Products.MimetypesRegistry.MimeTypeItem import MimeTypeItem
00002 from Products.MimetypesRegistry.common import MimeTypeException
00003 
00004 
00005 map = {
00006     # '.extension' : 'mimetype',
00007     '.svg' : 'image/svg+xml', # scaleable vector graphics
00008     '.pjpg' : 'image/pjpeg', # scaleable vector graphics
00009     
00010 }
00011 
00012 def initialize(registry):
00013     #Find things that are not in the specially registered mimetypes
00014     #and add them using some default policy, none of these will impl
00015     #iclassifier
00016     for ext, mt in map.items():
00017         if ext[0] == '.':
00018             ext = ext[1:]
00019         
00020         if registry.lookupExtension(ext):
00021             continue
00022 
00023         try:
00024             mto =  registry.lookup(mt)
00025         except MimeTypeException:
00026             # malformed MIME type
00027             continue
00028         if mto:
00029             mto = mto[0]
00030             if not ext in mto.extensions:
00031                 registry.register_extension(ext, mto)
00032                 mto.extensions += (ext, )
00033             continue
00034         isBin = mt.split('/', 1)[0] != "text"
00035         registry.register(MimeTypeItem(mt, (mt,), (ext,), isBin))