[integrity] temporary fix auto-delete relation (see 4673:6f8b925a29f4 and 4642:921737d2e3a8): we want no read perms, though we want to check delete perms. Should be properly fixed in 3.7 once we've proper security control and [unsafe_]execute behaviour on the repository side
"""mime type transformation engine for cubicweb, based on mtconverter
:organization: Logilab
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
"""
__docformat__ = "restructuredtext en"
from logilab import mtconverter
from logilab.mtconverter.engine import TransformEngine
from logilab.mtconverter.transform import Transform
from cubicweb.uilib import rest_publish, html_publish, remove_html_tags
HTML_MIMETYPES = ('text/html', 'text/xhtml', 'application/xhtml+xml')
# CubicWeb specific transformations
class rest_to_html(Transform):
inputs = ('text/rest', 'text/x-rst')
output = 'text/html'
def _convert(self, trdata):
return rest_publish(trdata.appobject, trdata.decode())
class html_to_html(Transform):
inputs = HTML_MIMETYPES
output = 'text/html'
def _convert(self, trdata):
return html_publish(trdata.appobject, trdata.data)
# Instantiate and configure the transformation engine
mtconverter.UNICODE_POLICY = 'replace'
ENGINE = TransformEngine()
ENGINE.add_transform(rest_to_html())
ENGINE.add_transform(html_to_html())
HAS_PIL_TRANSFORMS = False
HAS_PYGMENTS_TRANSFORMS = False
class html_to_text(Transform):
inputs = HTML_MIMETYPES
output = 'text/plain'
def _convert(self, trdata):
return remove_html_tags(trdata.data)
ENGINE.add_transform(html_to_text())