Source

collective.mediawiki / src / collective / mediawiki / setuphandlers.py

Full commit
from Products.CMFCore.utils import getToolByName
from collective.mediawiki.transforms import TextMediawiki

import logging
logger = logging.getLogger('collective.mediawiki')

def install(self):
    mimetypes_registry = getToolByName(self, 'mimetypes_registry')
    mimetypes_registry.register(TextMediawiki())
    transform_tool = getToolByName(self, 'portal_transforms')
    try:
        transform_tool.manage_delObjects(['mediawiki_to_html'])
    except Exception, e:
        logger.info("no mediawiki_to_html transform installed yet")
    transform_tool.manage_addTransform('mediawiki_to_html', 'collective.mediawiki.transforms')
    
def uninstall(self):
    mimetypes_registry = getToolByName(self, 'mimetypes_registry')
    transform_tool = getToolByName(self, 'portal_transforms')
    try:
        mimetypes_registry.unregister(TextMediawiki())
    except Exception, e:
        logger.warn('no mediawiki mimetype to uninstall')
    try:
        transform_tool.manage_delObjects(['mediawiki_to_html'])
    except Exception, e:
        logger.warn('no mediawiki transform to uninstall')