diff --git a/doc/version.txt b/doc/version.txt index 844f6a9..d2b13eb 100644 --- a/doc/version.txt +++ b/doc/version.txt @@ -1 +1 @@ -0.6.3 +0.6.4 diff --git a/gen/plone25/mixins/__init__.py b/gen/plone25/mixins/__init__.py index 091a3ef..5d3e331 100644 --- a/gen/plone25/mixins/__init__.py +++ b/gen/plone25/mixins/__init__.py @@ -1162,6 +1162,18 @@ class BaseMixin: if '-' in res: res = res[:res.find('-')] return res + def formatText(self, text, format='html'): + '''Produces a representation of p_text into the desired p_format, which + is 'html' by default.''' + if format in ('html', 'xhtml'): + res = text.replace('\r\n', '
').replace('\n', '
') + elif format == 'js': + res = text.replace('\r\n', '').replace('\n', '') + res = res.replace("'", "\\'") + else: + res = text + return res + def translate(self, label, mapping={}, domain=None, default=None, language=None, format='html'): '''Translates a given p_label into p_domain with p_mapping.''' @@ -1196,11 +1208,7 @@ class BaseMixin: if not res: res = label else: # Perform replacements, according to p_format. - if format == 'html': - res = res.replace('\r\n', '
').replace('\n', '
') - elif format == 'js': - res = res.replace('\r\n', '').replace('\n', '') - res = res.replace("'", "\\'") + res = self.formatText(res, format) # Perform variable replacements for name, repl in mapping.iteritems(): res = res.replace('${%s}' % name, repl) diff --git a/gen/plone25/skin/widgets/string.pt b/gen/plone25/skin/widgets/string.pt index 1854aa3..945297d 100644 --- a/gen/plone25/skin/widgets/string.pt +++ b/gen/plone25/skin/widgets/string.pt @@ -13,7 +13,7 @@ + tal:replace="structure python: contextObj.formatText(value, format='html')"/> diff --git a/gen/plone25/wrappers/__init__.py b/gen/plone25/wrappers/__init__.py index ef08767..513e4d0 100644 --- a/gen/plone25/wrappers/__init__.py +++ b/gen/plone25/wrappers/__init__.py @@ -378,7 +378,7 @@ class AbstractWrapper: self.o.reindexObject() def export(self, at='string', format='xml', include=None, exclude=None): - '''Creates an "exportable" version of this object. p_format is XML by + '''Creates an "exportable" version of this object. p_format is "xml" by default, but can also be "csv". If p_format is: * "xml", if p_at is "string", this method returns the XML version, without the XML prologue. Else, (a) if not p_at, the XML @@ -427,4 +427,9 @@ class AbstractWrapper: p_data must be a dictionary whose keys are field names (strings) and whose values are the previous field values.''' self.o.addDataChange(data) + + def formatText(self, text, format='html'): + '''Produces a representation of p_text into the desired p_format, which + is 'html' by default.''' + return self.o.formatText(text, format) # ------------------------------------------------------------------------------ diff --git a/pod/converter.py b/pod/converter.py index a12cf67..80d9e3d 100644 --- a/pod/converter.py +++ b/pod/converter.py @@ -80,12 +80,12 @@ class Converter: '''Returns the absolute path of the input file. In fact, it returns a tuple with some URL version of the path for OO as the first element and the absolute path as the second element.''' - import uno + import unohelper if not os.path.exists(docPath) and not os.path.isfile(docPath): raise ConverterError(DOC_NOT_FOUND % docPath) docAbsPath = os.path.abspath(docPath) # Return one path for OO, one path for me. - return uno.systemPathToFileUrl(docAbsPath), docAbsPath + return unohelper.systemPathToFileUrl(docAbsPath), docAbsPath def getResultFilter(self): '''Based on the result type, identifies which OO filter to use for the @@ -110,7 +110,7 @@ class Converter: different extension: . ''' - import uno + import unohelper baseName = os.path.splitext(self.docPath)[0] if self.resultType != self.inputType: res = '%s.%s' % (baseName, self.resultType) @@ -121,7 +121,7 @@ class Converter: f.write('Hello') f.close() os.remove(res) - return uno.systemPathToFileUrl(res) + return unohelper.systemPathToFileUrl(res) except (OSError, IOError), ioe: raise ConverterError(CANNOT_WRITE_RESULT % (res, ioe))