Back to index

plone3  3.1.7
html_body.py
Go to the documentation of this file.
00001 from Products.PortalTransforms.interfaces import itransform
00002 from Products.CMFDefault.utils import bodyfinder
00003 
00004 class HTMLBody:
00005     """Simple transform which extracts the content of the body tag"""
00006 
00007     __implements__ = itransform
00008 
00009     __name__ = "html_body"
00010     inputs   = ('text/html',)
00011     output = "text/html"
00012 
00013     def __init__(self, name=None):
00014         self.config_metadata = {
00015             'inputs' : ('list', 'Inputs', 'Input(s) MIME type. Change with care.'),
00016             }
00017         if name:
00018             self.__name__ = name
00019 
00020     def name(self):
00021         return self.__name__
00022 
00023     def __getattr__(self, attr):
00024         if attr == 'inputs':
00025             return self.config['inputs']
00026         if attr == 'output':
00027             return self.config['output']
00028         raise AttributeError(attr)
00029 
00030     def convert(self, orig, data, **kwargs):
00031         body = bodyfinder(orig)
00032         data.setData(body)
00033         return data
00034 
00035 def register():
00036     return HTMLBody()