[Testbot] Plone 4.3 - Python 2.6 - Build # 2414 - Still failing! - 40 failure(s)
jenkins at plone.org
jenkins at plone.org
Sat Oct 11 22:54:46 UTC 2014
-------------------------------------------------------------------------------
Plone 4.3 - Python 2.6 - Build # 2414 - Still Failing!
-------------------------------------------------------------------------------
http://jenkins.plone.org/job/plone-4.3-python-2.6/2414/
-------------------------------------------------------------------------------
CHANGES
-------------------------------------------------------------------------------
Repository: plone.supermodel
Branch: refs/heads/master
Date: 2014-10-10T08:34:33+03:00
Author: Asko Soukka (datakurre) <asko.soukka at iki.fi>
Commit: https://github.com/plone/plone.supermodel/commit/d7e3eab1e47633627b0c3b78a8b76d3731415bed
Implement i18n serializer
Files changed:
M plone/supermodel/schema.txt
M plone/supermodel/serializer.py
M plone/supermodel/utils.py
M setup.py
diff --git a/plone/supermodel/schema.txt b/plone/supermodel/schema.txt
index ce35f8c..540955d 100644
--- a/plone/supermodel/schema.txt
+++ b/plone/supermodel/schema.txt
@@ -107,7 +107,7 @@ In addition to parsing, we can serialize a model to an XML representation:
>>> from plone.supermodel import serializeModel
>>> print serializeModel(model) # doctest: +NORMALIZE_WHITESPACE
- <model xmlns="http://namespaces.plone.org/supermodel/schema">
+ <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns="http://namespaces.plone.org/supermodel/schema">
<schema>
<field name="title" type="zope.schema.TextLine">
<title>Title</title>
@@ -195,7 +195,7 @@ of just a single schema using serializeSchema():
>>> from plone.supermodel import serializeSchema
>>> print serializeSchema(ITestContent) # doctest: +NORMALIZE_WHITESPACE
- <model xmlns="http://namespaces.plone.org/supermodel/schema">
+ <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns="http://namespaces.plone.org/supermodel/schema">
<schema>
<field name="title" type="zope.schema.TextLine">
<title>Title</title>
@@ -208,7 +208,7 @@ of just a single schema using serializeSchema():
</model>
>>> print serializeSchema(ITestMetadata, name=u"metadata") # doctest: +NORMALIZE_WHITESPACE
- <model xmlns="http://namespaces.plone.org/supermodel/schema">
+ <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns="http://namespaces.plone.org/supermodel/schema">
<schema name="metadata">
<field name="created" type="zope.schema.Datetime">
<required>False</required>
@@ -249,7 +249,7 @@ Then, let's define a schema that is based on this interface.
>>> schema = """\
... <?xml version="1.0" encoding="UTF-8"?>
- ... <model xmlns="http://namespaces.plone.org/supermodel/schema">
+ ... <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns="http://namespaces.plone.org/supermodel/schema">
... <schema based-on="plone.supermodel.tests.IBase">
... <field type="zope.schema.Text" name="description">
... <title>Description</title>
@@ -291,7 +291,7 @@ We should also verify that the description field was indeed overridden:
Finally, let's verify that bases are preserved upon serialisation:
>>> print serializeSchema(model.schema) # doctest: +NORMALIZE_WHITESPACE
- <model xmlns="http://namespaces.plone.org/supermodel/schema">
+ <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns="http://namespaces.plone.org/supermodel/schema">
<schema based-on="plone.supermodel.tests.IBase">
<field name="description" type="zope.schema.Text">
<description>A short summary</description>
@@ -404,7 +404,7 @@ When we serialise a schema with fieldsets, fields will be grouped by
fieldset.
>>> print serializeModel(model) # doctest: +NORMALIZE_WHITESPACE
- <model xmlns="http://namespaces.plone.org/supermodel/schema">
+ <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns="http://namespaces.plone.org/supermodel/schema">
<schema>
<field name="title" type="zope.schema.TextLine">
<title>Title</title>
@@ -483,7 +483,7 @@ in action.
The model's serialization should include the invariant.
>>> print serializeModel(model) # doctest: +NORMALIZE_WHITESPACE
- <model xmlns="http://namespaces.plone.org/supermodel/schema">
+ <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns="http://namespaces.plone.org/supermodel/schema">
<schema>
<invariant>plone.supermodel.tests.dummy_invariant</invariant>
<invariant>plone.supermodel.tests.dummy_invariant_prime</invariant>
@@ -552,6 +552,14 @@ as a zope.i18nmessageid message id rather than a basic Unicode string::
<type 'zope.i18nmessageid.message.Message'>
>>> msgid.default
u'Title'
+ >>> print serializeModel(model) # doctest: +NORMALIZE_WHITESPACE
+ <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns="http://namespaces.plone.org/supermodel/schema" i18n:domain="plone.supermodel">
+ <schema>
+ <field name="title" type="zope.schema.TextLine">
+ <title i18n:translate="supermodel_test_title">Title</title>
+ </field>
+ </schema>
+ </model>
Creating custom metadata handlers
---------------------------------
@@ -649,7 +657,7 @@ Of course, we can also serialize the schema back to XML. Here, the 'prefix'
set in the utility (if any) will be used by default.
>>> print serializeModel(model) # doctest: +NORMALIZE_WHITESPACE
- <model xmlns:ui="http://namespaces.acme.com/ui" xmlns="http://namespaces.plone.org/supermodel/schema">
+ <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns:ui="http://namespaces.acme.com/ui" xmlns="http://namespaces.plone.org/supermodel/schema">
<schema ui:layout="horizontal">
<field name="title" type="zope.schema.TextLine" ui:widget="largetype">
<title>Title</title>
@@ -661,4 +669,4 @@ set in the utility (if any) will be used by default.
<title>Description</title>
</field>
</schema>
- </model>
\ No newline at end of file
+ </model>
diff --git a/plone/supermodel/serializer.py b/plone/supermodel/serializer.py
index b7017b1..55ae942 100644
--- a/plone/supermodel/serializer.py
+++ b/plone/supermodel/serializer.py
@@ -9,13 +9,14 @@
from plone.supermodel.interfaces import ISchemaMetadataHandler
from plone.supermodel.interfaces import IFieldMetadataHandler
+from plone.supermodel.interfaces import I18N_NAMESPACE
from plone.supermodel.interfaces import XML_NAMESPACE
from plone.supermodel.interfaces import FIELDSETS_KEY
from plone.supermodel.interfaces import IFieldNameExtractor
from plone.supermodel.model import Schema
-from plone.supermodel.utils import sortedFields, prettyXML
+from plone.supermodel.utils import ns, sortedFields, prettyXML
from lxml import etree
@@ -51,7 +52,7 @@ def serialize(model):
schema_metadata_handlers = tuple(getUtilitiesFor(ISchemaMetadataHandler))
field_metadata_handlers = tuple(getUtilitiesFor(IFieldMetadataHandler))
- nsmap = {}
+ nsmap = {'i18n': I18N_NAMESPACE}
for name, handler in schema_metadata_handlers + field_metadata_handlers:
namespace, prefix = handler.namespace, handler.prefix
if namespace is not None and prefix is not None:
@@ -123,6 +124,17 @@ def writeField(field, parentElement):
xml.append(schema_element)
+ # handle i18n
+ i18n_domain = xml.get(ns('domain', prefix=I18N_NAMESPACE))
+ for node in xml.xpath('//*[@i18n:translate]', namespaces=nsmap):
+ domain = node.get(ns('domain', prefix=I18N_NAMESPACE), i18n_domain)
+ if i18n_domain is None:
+ i18n_domain = domain
+ if domain == i18n_domain:
+ node.attrib.pop(ns('domain', prefix=I18N_NAMESPACE))
+ if i18n_domain:
+ xml.set(ns('domain', prefix=I18N_NAMESPACE), i18n_domain)
+
return prettyXML(xml)
diff --git a/plone/supermodel/utils.py b/plone/supermodel/utils.py
index 65988f0..cad7d2f 100644
--- a/plone/supermodel/utils.py
+++ b/plone/supermodel/utils.py
@@ -175,6 +175,15 @@ def valueToElement(field, value, name=None, force=False):
converter = IToUnicode(field)
child.text = converter.toUnicode(value)
+ # handle i18n
+ if isinstance(value, Message):
+ child.set(ns('domain', I18N_NAMESPACE), value.domain)
+ if not value.default:
+ child.set(ns('translate', I18N_NAMESPACE), '')
+ else:
+ child.set(ns('translate', I18N_NAMESPACE), child.text)
+ child.text = converter.toUnicode(value.default)
+
return child
diff --git a/setup.py b/setup.py
index 65c85c3..15a6c52 100644
--- a/setup.py
+++ b/setup.py
@@ -45,6 +45,7 @@ def read(*rnames):
'setuptools',
'lxml',
'zope.component',
+ 'zope.i18nmessageid',
'zope.interface',
ZOPESCHEMA,
'zope.deferredimport',
Repository: plone.supermodel
Branch: refs/heads/master
Date: 2014-10-10T08:35:23+03:00
Author: Asko Soukka (datakurre) <asko.soukka at iki.fi>
Commit: https://github.com/plone/plone.supermodel/commit/018a6c9cd53750ace826ef5e0273a47271162fdb
Update changelog
Files changed:
M CHANGES.rst
diff --git a/CHANGES.rst b/CHANGES.rst
index 8fe09d0..4892cc2 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,8 +4,8 @@ Changelog
1.2.6 (unreleased)
------------------
-- Nothing changed yet.
-
+- Add i18n serialization from schema value to XML model
+ [datakurre]
1.2.5 (2014-09-07)
------------------
Repository: plone.supermodel
Branch: refs/heads/master
Date: 2014-10-10T08:43:21+03:00
Author: Asko Soukka (datakurre) <asko.soukka at iki.fi>
Commit: https://github.com/plone/plone.supermodel/commit/d6ba0285b26881ceaf688a93e3adfd06706387f3
Fix XML model to support multiple different i18n domains
Files changed:
M plone/supermodel/schema.txt
M plone/supermodel/utils.py
diff --git a/plone/supermodel/schema.txt b/plone/supermodel/schema.txt
index 540955d..4bcbc0f 100644
--- a/plone/supermodel/schema.txt
+++ b/plone/supermodel/schema.txt
@@ -541,6 +541,15 @@ as a zope.i18nmessageid message id rather than a basic Unicode string::
... <title i18n:translate="supermodel_test_title">Title</title>
... </field>
...
+ ... <field type="zope.schema.TextLine" name="description">
+ ... <title i18n:translate="">description</title>
+ ... </field>
+ ...
+ ... <field type="zope.schema.TextLine" name="feature">
+ ... <title i18n:translate="domain_test"
+ ... i18n:domain="other">feature</title>
+ ... </field>
+ ...
... </schema>
... </model>
... """
@@ -558,6 +567,12 @@ as a zope.i18nmessageid message id rather than a basic Unicode string::
<field name="title" type="zope.schema.TextLine">
<title i18n:translate="supermodel_test_title">Title</title>
</field>
+ <field name="description" type="zope.schema.TextLine">
+ <title i18n:translate="">description</title>
+ </field>
+ <field name="feature" type="zope.schema.TextLine">
+ <title i18n:domain="other" i18n:translate="domain_test">feature</title>
+ </field>
</schema>
</model>
diff --git a/plone/supermodel/utils.py b/plone/supermodel/utils.py
index cad7d2f..34f7db2 100644
--- a/plone/supermodel/utils.py
+++ b/plone/supermodel/utils.py
@@ -132,11 +132,13 @@ def elementToValue(field, element, default=_marker):
# handle i18n
if isinstance(value, unicode) and parseinfo.i18n_domain is not None:
translate_attr = ns('translate', I18N_NAMESPACE)
+ domain_attr = ns('domain', I18N_NAMESPACE)
msgid = element.attrib.get(translate_attr)
+ domain = element.attrib.get(domain_attr, parseinfo.i18n_domain)
if msgid:
- value = Message(msgid, domain=parseinfo.i18n_domain, default=value)
+ value = Message(msgid, domain=domain, default=value)
elif translate_attr in element.attrib:
- value = Message(value, domain=parseinfo.i18n_domain)
+ value = Message(value, domain=domain)
return value
Repository: plone.supermodel
Branch: refs/heads/master
Date: 2014-10-12T00:29:54+02:00
Author: Jens W. Klein (jensens) <jk at kleinundpartner.at>
Commit: https://github.com/plone/plone.supermodel/commit/5d4f76a6ec4341fe4effbec3217590c002e1517b
Merge pull request #9 from plone/datakurre-i18nserializer
Add missing i18n serialization from schema value to XML model
Files changed:
M CHANGES.rst
M plone/supermodel/schema.txt
M plone/supermodel/serializer.py
M plone/supermodel/utils.py
M setup.py
diff --git a/CHANGES.rst b/CHANGES.rst
index 8fe09d0..4892cc2 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,8 +4,8 @@ Changelog
1.2.6 (unreleased)
------------------
-- Nothing changed yet.
-
+- Add i18n serialization from schema value to XML model
+ [datakurre]
1.2.5 (2014-09-07)
------------------
diff --git a/plone/supermodel/schema.txt b/plone/supermodel/schema.txt
index ce35f8c..4bcbc0f 100644
--- a/plone/supermodel/schema.txt
+++ b/plone/supermodel/schema.txt
@@ -107,7 +107,7 @@ In addition to parsing, we can serialize a model to an XML representation:
>>> from plone.supermodel import serializeModel
>>> print serializeModel(model) # doctest: +NORMALIZE_WHITESPACE
- <model xmlns="http://namespaces.plone.org/supermodel/schema">
+ <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns="http://namespaces.plone.org/supermodel/schema">
<schema>
<field name="title" type="zope.schema.TextLine">
<title>Title</title>
@@ -195,7 +195,7 @@ of just a single schema using serializeSchema():
>>> from plone.supermodel import serializeSchema
>>> print serializeSchema(ITestContent) # doctest: +NORMALIZE_WHITESPACE
- <model xmlns="http://namespaces.plone.org/supermodel/schema">
+ <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns="http://namespaces.plone.org/supermodel/schema">
<schema>
<field name="title" type="zope.schema.TextLine">
<title>Title</title>
@@ -208,7 +208,7 @@ of just a single schema using serializeSchema():
</model>
>>> print serializeSchema(ITestMetadata, name=u"metadata") # doctest: +NORMALIZE_WHITESPACE
- <model xmlns="http://namespaces.plone.org/supermodel/schema">
+ <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns="http://namespaces.plone.org/supermodel/schema">
<schema name="metadata">
<field name="created" type="zope.schema.Datetime">
<required>False</required>
@@ -249,7 +249,7 @@ Then, let's define a schema that is based on this interface.
>>> schema = """\
... <?xml version="1.0" encoding="UTF-8"?>
- ... <model xmlns="http://namespaces.plone.org/supermodel/schema">
+ ... <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns="http://namespaces.plone.org/supermodel/schema">
... <schema based-on="plone.supermodel.tests.IBase">
... <field type="zope.schema.Text" name="description">
... <title>Description</title>
@@ -291,7 +291,7 @@ We should also verify that the description field was indeed overridden:
Finally, let's verify that bases are preserved upon serialisation:
>>> print serializeSchema(model.schema) # doctest: +NORMALIZE_WHITESPACE
- <model xmlns="http://namespaces.plone.org/supermodel/schema">
+ <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns="http://namespaces.plone.org/supermodel/schema">
<schema based-on="plone.supermodel.tests.IBase">
<field name="description" type="zope.schema.Text">
<description>A short summary</description>
@@ -404,7 +404,7 @@ When we serialise a schema with fieldsets, fields will be grouped by
fieldset.
>>> print serializeModel(model) # doctest: +NORMALIZE_WHITESPACE
- <model xmlns="http://namespaces.plone.org/supermodel/schema">
+ <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns="http://namespaces.plone.org/supermodel/schema">
<schema>
<field name="title" type="zope.schema.TextLine">
<title>Title</title>
@@ -483,7 +483,7 @@ in action.
The model's serialization should include the invariant.
>>> print serializeModel(model) # doctest: +NORMALIZE_WHITESPACE
- <model xmlns="http://namespaces.plone.org/supermodel/schema">
+ <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns="http://namespaces.plone.org/supermodel/schema">
<schema>
<invariant>plone.supermodel.tests.dummy_invariant</invariant>
<invariant>plone.supermodel.tests.dummy_invariant_prime</invariant>
@@ -541,6 +541,15 @@ as a zope.i18nmessageid message id rather than a basic Unicode string::
... <title i18n:translate="supermodel_test_title">Title</title>
... </field>
...
+ ... <field type="zope.schema.TextLine" name="description">
+ ... <title i18n:translate="">description</title>
+ ... </field>
+ ...
+ ... <field type="zope.schema.TextLine" name="feature">
+ ... <title i18n:translate="domain_test"
+ ... i18n:domain="other">feature</title>
+ ... </field>
+ ...
... </schema>
... </model>
... """
@@ -552,6 +561,20 @@ as a zope.i18nmessageid message id rather than a basic Unicode string::
<type 'zope.i18nmessageid.message.Message'>
>>> msgid.default
u'Title'
+ >>> print serializeModel(model) # doctest: +NORMALIZE_WHITESPACE
+ <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns="http://namespaces.plone.org/supermodel/schema" i18n:domain="plone.supermodel">
+ <schema>
+ <field name="title" type="zope.schema.TextLine">
+ <title i18n:translate="supermodel_test_title">Title</title>
+ </field>
+ <field name="description" type="zope.schema.TextLine">
+ <title i18n:translate="">description</title>
+ </field>
+ <field name="feature" type="zope.schema.TextLine">
+ <title i18n:domain="other" i18n:translate="domain_test">feature</title>
+ </field>
+ </schema>
+ </model>
Creating custom metadata handlers
---------------------------------
@@ -649,7 +672,7 @@ Of course, we can also serialize the schema back to XML. Here, the 'prefix'
set in the utility (if any) will be used by default.
>>> print serializeModel(model) # doctest: +NORMALIZE_WHITESPACE
- <model xmlns:ui="http://namespaces.acme.com/ui" xmlns="http://namespaces.plone.org/supermodel/schema">
+ <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns:ui="http://namespaces.acme.com/ui" xmlns="http://namespaces.plone.org/supermodel/schema">
<schema ui:layout="horizontal">
<field name="title" type="zope.schema.TextLine" ui:widget="largetype">
<title>Title</title>
@@ -661,4 +684,4 @@ set in the utility (if any) will be used by default.
<title>Description</title>
</field>
</schema>
- </model>
\ No newline at end of file
+ </model>
diff --git a/plone/supermodel/serializer.py b/plone/supermodel/serializer.py
index b7017b1..55ae942 100644
--- a/plone/supermodel/serializer.py
+++ b/plone/supermodel/serializer.py
@@ -9,13 +9,14 @@
from plone.supermodel.interfaces import ISchemaMetadataHandler
from plone.supermodel.interfaces import IFieldMetadataHandler
+from plone.supermodel.interfaces import I18N_NAMESPACE
from plone.supermodel.interfaces import XML_NAMESPACE
from plone.supermodel.interfaces import FIELDSETS_KEY
from plone.supermodel.interfaces import IFieldNameExtractor
from plone.supermodel.model import Schema
-from plone.supermodel.utils import sortedFields, prettyXML
+from plone.supermodel.utils import ns, sortedFields, prettyXML
from lxml import etree
@@ -51,7 +52,7 @@ def serialize(model):
schema_metadata_handlers = tuple(getUtilitiesFor(ISchemaMetadataHandler))
field_metadata_handlers = tuple(getUtilitiesFor(IFieldMetadataHandler))
- nsmap = {}
+ nsmap = {'i18n': I18N_NAMESPACE}
for name, handler in schema_metadata_handlers + field_metadata_handlers:
namespace, prefix = handler.namespace, handler.prefix
if namespace is not None and prefix is not None:
@@ -123,6 +124,17 @@ def writeField(field, parentElement):
xml.append(schema_element)
+ # handle i18n
+ i18n_domain = xml.get(ns('domain', prefix=I18N_NAMESPACE))
+ for node in xml.xpath('//*[@i18n:translate]', namespaces=nsmap):
+ domain = node.get(ns('domain', prefix=I18N_NAMESPACE), i18n_domain)
+ if i18n_domain is None:
+ i18n_domain = domain
+ if domain == i18n_domain:
+ node.attrib.pop(ns('domain', prefix=I18N_NAMESPACE))
+ if i18n_domain:
+ xml.set(ns('domain', prefix=I18N_NAMESPACE), i18n_domain)
+
return prettyXML(xml)
diff --git a/plone/supermodel/utils.py b/plone/supermodel/utils.py
index 65988f0..34f7db2 100644
--- a/plone/supermodel/utils.py
+++ b/plone/supermodel/utils.py
@@ -132,11 +132,13 @@ def elementToValue(field, element, default=_marker):
# handle i18n
if isinstance(value, unicode) and parseinfo.i18n_domain is not None:
translate_attr = ns('translate', I18N_NAMESPACE)
+ domain_attr = ns('domain', I18N_NAMESPACE)
msgid = element.attrib.get(translate_attr)
+ domain = element.attrib.get(domain_attr, parseinfo.i18n_domain)
if msgid:
- value = Message(msgid, domain=parseinfo.i18n_domain, default=value)
+ value = Message(msgid, domain=domain, default=value)
elif translate_attr in element.attrib:
- value = Message(value, domain=parseinfo.i18n_domain)
+ value = Message(value, domain=domain)
return value
@@ -175,6 +177,15 @@ def valueToElement(field, value, name=None, force=False):
converter = IToUnicode(field)
child.text = converter.toUnicode(value)
+ # handle i18n
+ if isinstance(value, Message):
+ child.set(ns('domain', I18N_NAMESPACE), value.domain)
+ if not value.default:
+ child.set(ns('translate', I18N_NAMESPACE), '')
+ else:
+ child.set(ns('translate', I18N_NAMESPACE), child.text)
+ child.text = converter.toUnicode(value.default)
+
return child
diff --git a/setup.py b/setup.py
index 65c85c3..15a6c52 100644
--- a/setup.py
+++ b/setup.py
@@ -45,6 +45,7 @@ def read(*rnames):
'setuptools',
'lxml',
'zope.component',
+ 'zope.i18nmessageid',
'zope.interface',
ZOPESCHEMA,
'zope.deferredimport',
-------------------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CHANGES.log
Type: application/octet-stream
Size: 22651 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-testbot/attachments/20141011/29d0eddb/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: build.log
Type: application/octet-stream
Size: 279143 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-testbot/attachments/20141011/29d0eddb/attachment-0003.obj>
More information about the Testbot
mailing list