Nuxeo mailing list archives
[CPS-devel] GenericSetup vs.non-ASCII content --- stopgap patch
Julien Anguenot
ja at nuxeo.com
Thu Jun 1 00:43:42 CEST 2006
Yves Bastide wrote:
> Hi,
>
> GenericSetup is cursed with Zope2's strings-are-str attitude; thus e.g.
> a type with a non-ASCII description is unexportable.
>
> Since CPS's current encoding is iso8859-15, the dirty bug attached
> exports iso8859-15 xml files: the DOM tree is (hopefully) built in
> Unicode, then encoded in Latin 9.
>
> Best regards,
>
> yves
>
>
> ------------------------------------------------------------------------
>
> Index: GenericSetup/utils.py
> ===================================================================
> --- GenericSetup/utils.py (revision 45483)
> +++ GenericSetup/utils.py (working copy)
> @@ -339,6 +339,11 @@
> """minidom element with 'pretty' XML output.
> """
>
> + def setAttribute(self, attname, value):
> + if isinstance(value, str):
> + value = value.decode('iso8859-15')
> + return Element.setAttribute(self, attname, value)
> +
> def writexml(self, writer, indent="", addindent="", newl=""):
> # indent = current indentation
> # addindent = indentation to add to higher levels
> @@ -400,6 +405,11 @@
> e = _Element(qualifiedName, namespaceURI, prefix)
> e.ownerDocument = self
> return e
> +
> + def createTextNode(self, data):
> + if isinstance(data, str):
> + data = data.decode('iso8859-15')
> + return Document.createTextNode(self, data)
>
> def writexml(self, writer, indent="", addindent="", newl="",
> encoding = None):
> @@ -496,7 +506,7 @@
> """Export the object as a file body.
> """
> self._doc.appendChild(self._exportNode())
> - return self._doc.toprettyxml(' ')
> + return self._doc.toprettyxml(' ', encoding='iso8859-15')
>
> def _importBody(self, body):
> """Import the object from the file body.
> @@ -623,8 +633,10 @@
> else:
> if prop_map.get('type') == 'boolean':
> prop = str(bool(prop))
> + elif isinstance(prop, str):
> + prop = prop.decode('iso8859-15')
> elif not isinstance(prop, basestring):
> - prop = str(prop)
> + prop = unicode(prop)
> child = self._doc.createTextNode(prop)
> node.appendChild(child)
>
>
Could you attach the patch over this :
http://svn.nuxeo.org/trac/pub/ticket/1529
J.
--
Julien Anguenot | Nuxeo R&D (Paris, France)
Open Source ECM - www.nuxeo.com
CPS Platform - http://www.cps-project.org
Mobile: +33 (0) 6 72 57 57 66
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
Url : http://lists.nuxeo.com/pipermail/cps-devel/attachments/20060601/0d9bcbf7/signature.pgp
More information about the cps-devel
mailing list
This list archive provided by Nuxeo, the
leaders of open source ECM.
Check out the Nuxeo 5 open source,
standards-based ECM project.