Back to index

plone3  3.1.7
identity.py
Go to the documentation of this file.
00001 """
00002 A simple identity transform
00003 """
00004 
00005 __revision__ = '$Id: identity.py 4787 2005-08-19 21:43:41Z dreamcatcher $'
00006 
00007 from Products.PortalTransforms.interfaces import itransform
00008 
00009 class IdentityTransform:
00010     """ Identity transform
00011 
00012     return content unchanged.
00013     """
00014     __implements__ = (itransform,)
00015 
00016     __name__ = "rest_to_text"
00017 
00018     def __init__(self, name=None, **kwargs):
00019         self.config = {
00020             'inputs'       : ('text/x-rst',),
00021             'output'      : 'text/plain',
00022             }
00023         self.config_metadata = {
00024             'inputs'       : ('list', 'Inputs', 'Input(s) MIME type. Change with care.'),
00025             'output'      : ('string', 'Output', 'Output MIME type. Change with care.'),
00026             }
00027         self.config.update(kwargs)
00028 
00029     def __getattr__(self, attr):
00030         if attr == 'inputs':
00031             return self.config['inputs']
00032         if attr == 'output':
00033             return self.config['output']
00034         raise AttributeError(attr)
00035 
00036     def name(self):
00037         return self.__name__
00038 
00039     def convert(self, data, cache, **kwargs):
00040         cache.setData(data)
00041         return cache
00042 
00043 def register():
00044     return IdentityTransform()