Back to index

plone3  3.1.7
kupu2html.py
Go to the documentation of this file.
00001 # Portal transform for images with captions
00002 #
00003 # Transforming a non-standard field type to html on output is
00004 # probably a better way to do things than the original transform
00005 # which converts html to a non-standard field type.
00006 #
00007 # The transform is the same as the one done by html2captioned, but
00008 # this version expects to work on text/x-html-raw
00009 
00010 try:
00011     from Products.PortalTransforms.z3.interfaces import ITransform
00012 except ImportError:
00013     ITransform = None
00014 from Products.PortalTransforms.interfaces import itransform
00015 
00016 from Products.kupu.plone import html2captioned
00017 from Products.CMFCore.utils import getToolByName
00018 from zope.interface import implements
00019 
00020 class KupuOutputTransform(html2captioned.HTMLToCaptioned):
00021     """Transform which adds captions to images embedded in HTML"""
00022     if ITransform is not None:
00023         implements(ITransform)
00024     __implements__ = itransform
00025     __name__ = "kupu_raw_to_html"
00026     inputs = ('text/x-html-raw',)
00027     output = "text/html"
00028 
00029 def register():
00030     return KupuOutputTransform()
00031 
00032 def initialize():
00033     engine = getToolByName(portal, 'portal_transforms')
00034     engine.registerTransform(register())