|
Revision 19076, 1.1 kB
(checked in by sfermigier, 6 years ago)
|
Initial revision
|
- Property svn:eol-style set to
native
- Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 |
""" |
|---|
| 2 |
A simple identity transform |
|---|
| 3 |
""" |
|---|
| 4 |
|
|---|
| 5 |
__revision__ = '$Id$' |
|---|
| 6 |
|
|---|
| 7 |
from Products.PortalTransforms.interfaces import itransform |
|---|
| 8 |
|
|---|
| 9 |
class IdentityTransform: |
|---|
| 10 |
""" Identity transform |
|---|
| 11 |
|
|---|
| 12 |
return content unchanged. |
|---|
| 13 |
""" |
|---|
| 14 |
__implements__ = (itransform,) |
|---|
| 15 |
|
|---|
| 16 |
__name__ = "rest_to_text" |
|---|
| 17 |
|
|---|
| 18 |
def __init__(self, name=None, **kwargs): |
|---|
| 19 |
self.config = { |
|---|
| 20 |
'inputs' : ('text/x-rst',), |
|---|
| 21 |
'output' : 'text/plain', |
|---|
| 22 |
} |
|---|
| 23 |
self.config_metadata = { |
|---|
| 24 |
'inputs' : ('list', 'Inputs', 'Input(s) MIME type. Change with care.'), |
|---|
| 25 |
'output' : ('string', 'Output', 'Output MIME type. Change with care.'), |
|---|
| 26 |
} |
|---|
| 27 |
self.config.update(kwargs) |
|---|
| 28 |
|
|---|
| 29 |
def __getattr__(self, attr): |
|---|
| 30 |
if attr == 'inputs': |
|---|
| 31 |
return self.config['inputs'] |
|---|
| 32 |
if attr == 'output': |
|---|
| 33 |
return self.config['output'] |
|---|
| 34 |
raise AttributeError(attr) |
|---|
| 35 |
|
|---|
| 36 |
def name(self): |
|---|
| 37 |
return self.__name__ |
|---|
| 38 |
|
|---|
| 39 |
def convert(self, data, cache, **kwargs): |
|---|
| 40 |
cache.setData(data) |
|---|
| 41 |
return cache |
|---|
| 42 |
|
|---|
| 43 |
def register(): |
|---|
| 44 |
return IdentityTransform() |
|---|