-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Branch: refs/heads/master Date: 2020-04-02T18:26:23+02:00 Author: Alin Voinea (avoinea) <contact@avoinea.com> Commit: plone/plone.schema@1669a65 Refs #7 - Fix JSONField with default values saved to XML (#8) Refs #7 - Fix JSONField with default values saved to XML Files changed: A news/7.bugfix A plone/schema/tests/__init__.py A plone/schema/tests/test_doctests.py M plone/schema/jsonfield.py M setup.py
- Loading branch information
Showing
1 changed file
with
13 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
Repository: plone.restapi | ||
Repository: plone.schema | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2020-04-01T15:15:54+02:00 | ||
Author: Timo Stollenwerk (tisto) <stollenwerk@kitconcept.com> | ||
Commit: https://github.com/plone/plone.restapi/commit/2e01956e55a2f00e2c9b8f5932b86837437d60af | ||
Date: 2020-04-02T18:26:23+02:00 | ||
Author: Alin Voinea (avoinea) <contact@avoinea.com> | ||
Commit: https://github.com/plone/plone.schema/commit/1669a65ef44f3fea636bdde2589e09e1d61e232b | ||
|
||
Add performance tests for Plone 5.2.1. | ||
Refs #7 - Fix JSONField with default values saved to XML (#8) | ||
|
||
Refs #7 - Fix JSONField with default values saved to XML | ||
|
||
Files changed: | ||
A performance/plone-5.2.1-py3-imac-pro-20200401/jmeter-anonymous-read.png | ||
A performance/plone-5.2.1-py3-imac-pro-20200401/jmeter-authenticated-read.png | ||
A performance/plone-5.2.1-py3-imac-pro-20200401/jmeter-authenticated-write.png | ||
M performance/plone-5.2-py3-imac-pro-20191122/README.md | ||
A news/7.bugfix | ||
A plone/schema/tests/__init__.py | ||
A plone/schema/tests/test_doctests.py | ||
M plone/schema/jsonfield.py | ||
M setup.py | ||
|
||
b'diff --git a/performance/plone-5.2-py3-imac-pro-20191122/README.md b/performance/plone-5.2-py3-imac-pro-20191122/README.md\nindex f7275d89..1902086c 100644\n--- a/performance/plone-5.2-py3-imac-pro-20191122/README.md\n+++ b/performance/plone-5.2-py3-imac-pro-20191122/README.md\n@@ -29,6 +29,10 @@ make test-performance\n \n # Performance Test Plone 5.2 / Python 3\n \n-Hardware: iMac Pro\n+Hardware: iMac Pro (2017), 3,2 GHz-8-Core Inel Xeon W, 32 GB DDR4 RAM\n Date: 20191123\n- \n+\n+Hardware: iMac Pro (2017), 3,2 GHz-8-Core Inel Xeon W, 32 GB DDR4 RAM, iOS Catalina 10.15.4\n+Date: 20200401\n+\n+\ndiff --git a/performance/plone-5.2.1-py3-imac-pro-20200401/jmeter-anonymous-read.png b/performance/plone-5.2.1-py3-imac-pro-20200401/jmeter-anonymous-read.png\nnew file mode 100644\nindex 00000000..70f4ce67\nBinary files /dev/null and b/performance/plone-5.2.1-py3-imac-pro-20200401/jmeter-anonymous-read.png differ\ndiff --git a/performance/plone-5.2.1-py3-imac-pro-20200401/jmeter-authenticated-read.png b/performance/plone-5.2.1-py3-imac-pro-20200401/jmeter-authenticated-read.png\nnew file mode 100644\nindex 00000000..322bc658\nBinary files /dev/null and b/performance/plone-5.2.1-py3-imac-pro-20200401/jmeter-authenticated-read.png differ\ndiff --git a/performance/plone-5.2.1-py3-imac-pro-20200401/jmeter-authenticated-write.png b/performance/plone-5.2.1-py3-imac-pro-20200401/jmeter-authenticated-write.png\nnew file mode 100644\nindex 00000000..8e08e5bf\nBinary files /dev/null and b/performance/plone-5.2.1-py3-imac-pro-20200401/jmeter-authenticated-write.png differ\n' | ||
b'diff --git a/news/7.bugfix b/news/7.bugfix\nnew file mode 100644\nindex 0000000..6cf4897\n--- /dev/null\n+++ b/news/7.bugfix\n@@ -0,0 +1,2 @@\n+Fix JSONField with default values saved to `model_source` XML\n+[avoinea]\ndiff --git a/plone/schema/jsonfield.py b/plone/schema/jsonfield.py\nindex bd960c7..d07b7b8 100644\n--- a/plone/schema/jsonfield.py\n+++ b/plone/schema/jsonfield.py\n@@ -1,3 +1,6 @@\n+import ast\n+import json\n+import jsonschema\n from plone.schema import _\n from zope.interface import Attribute\n from zope.interface import implementer\n@@ -7,8 +10,11 @@\n from zope.schema.interfaces import WrongContainedType\n from zope.schema.interfaces import IFromUnicode\n \n-import json\n-import jsonschema\n+try:\n+ from json import JSONDecodeError\n+except ImportError:\n+ # Python 2\n+ JSONDecodeError = ValueError\n \n \n DEFAULT_JSON_SCHEMA = json.dumps({\n@@ -48,6 +54,23 @@ def _validate(self, value):\n raise WrongContainedType(e.message, self.__name__)\n \n def fromUnicode(self, value):\n- v = json.loads(value)\n+ """ Get value from unicode.\n+\n+ Value can be a valid JSON object:\n+\n+ >>> JSONField().fromUnicode(\'{"items": []}\')\n+ {\'items\': []}\n+\n+ or it can be a Pyhon dict stored as string:\n+\n+ >>> JSONField().fromUnicode("{\'items\': []}")\n+ {\'items\': []}\n+\n+ """\n+ try:\n+ v = json.loads(value)\n+ except JSONDecodeError:\n+ v = ast.literal_eval(value)\n+\n self.validate(v)\n return v\ndiff --git a/plone/schema/tests/__init__.py b/plone/schema/tests/__init__.py\nnew file mode 100644\nindex 0000000..bf3dd71\n--- /dev/null\n+++ b/plone/schema/tests/__init__.py\n@@ -0,0 +1,2 @@\n+""" Tests\n+"""\ndiff --git a/plone/schema/tests/test_doctests.py b/plone/schema/tests/test_doctests.py\nnew file mode 100644\nindex 0000000..9e4dbb2\n--- /dev/null\n+++ b/plone/schema/tests/test_doctests.py\n@@ -0,0 +1,23 @@\n+""" Tests\n+"""\n+import re\n+import six\n+import unittest\n+import doctest\n+\n+class Py23DocChecker(doctest.OutputChecker):\n+ def check_output(self, want, got, optionflags):\n+ if six.PY2:\n+ got = re.sub("u\'(.*?)\'", "\'\\\\1\'", want)\n+ got = re.sub(\' encoding="utf-8"\', \'\', want)\n+ # want = re.sub("b\'(.*?)\'", "\'\\\\1\'", want)\n+ return doctest.OutputChecker.check_output(self, want, got, optionflags)\n+\n+\n+def test_suite():\n+ return unittest.TestSuite((\n+ doctest.DocTestSuite(\n+ \'plone.schema.jsonfield\',\n+ checker=Py23DocChecker()\n+ ),\n+ ))\ndiff --git a/setup.py b/setup.py\nindex bc99234..9d087f1 100644\n--- a/setup.py\n+++ b/setup.py\n@@ -46,7 +46,8 @@\n \'zope.interface\',\n \'zope.schema\',\n ],\n- extras_require={\n- \'test\': [\'plone.app.testing\'],\n- },\n+ extras_require={\'test\': [\n+ \'six\',\n+ \'plone.app.testing\'\n+ ]},\n )\n' | ||
|