File:  [Repository] / kupuMPIWG / plone / kupu_plone_layer / convertContentForKupu.py
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Aug 30 17:10:22 2005 UTC (18 years, 9 months ago) by dwinter
Branches: first, MAIN
CVS tags: alpha, HEAD


## Script (Python) "convertContentForKupu"
##title=Convert content to HTML for editing with Kupu
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=fieldname, content
from Products.CMFCore.utils import getToolByName
from Products.PythonScripts.standard import structured_text, newline_to_br

field = context.getField(fieldname)
text_format = context.REQUEST.get('%s_text_format' % fieldname, context.getContentType(fieldname))

if len(content)==0 or 'html' in text_format.lower():
    return content
 
transforms = getToolByName(context, 'portal_transforms')
return transforms.convertTo('text/html', content, mimetype=text_format)

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>