Skip to content

Commit

Permalink
[fc] Repository: plone.app.dexterity
Browse files Browse the repository at this point in the history
Branch: refs/heads/master
Date: 2019-06-07T15:23:05+02:00
Author: ale-rt (ale-rt) <alessandro.pisa@gmail.com>
Commit: plone/plone.app.dexterity@a6420fe

Behavior should be saved as native strings

Fixes #296
Closes plone/Products.CMFPlone#2881

Files changed:
A news/296.bugfix
M plone/app/dexterity/browser/behaviors.py
M plone/app/dexterity/tests/editing.rst
  • Loading branch information
ale-rt committed Jun 7, 2019
1 parent 01d0092 commit 6e9bcf5
Showing 1 changed file with 12 additions and 41 deletions.
53 changes: 12 additions & 41 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,49 +1,20 @@
Repository: plone.namedfile
Repository: plone.app.dexterity


Branch: refs/heads/4.2.x
Date: 2019-05-30T19:55:18+02:00
Author: mauro (mamico) <mauro.amico@unibo.it>
Commit: https://github.com/plone/plone.namedfile/commit/e14189ee6f8fcfc35fc3e3b7419129f3304eaace
Branch: refs/heads/master
Date: 2019-06-07T15:23:05+02:00
Author: ale-rt (ale-rt) <alessandro.pisa@gmail.com>
Commit: https://github.com/plone/plone.app.dexterity/commit/a6420fe9db24e5f055265a45a48aa12ed565f3c8

fix multiple write during image requests
Behavior should be saved as native strings

Files changed:
A news/78.bugfix
M plone/namedfile/file.py

b'diff --git a/news/78.bugfix b/news/78.bugfix\nnew file mode 100644\nindex 0000000..e69de29\ndiff --git a/plone/namedfile/file.py b/plone/namedfile/file.py\nindex 1f63219..9b225b4 100644\n--- a/plone/namedfile/file.py\n+++ b/plone/namedfile/file.py\n@@ -409,7 +409,15 @@ def _setData(self, data):\n length = max(0, MAX_INFO_BYTES - start)\n firstbytes += self.getFirstBytes(start, length)\n res = getImageInfo(firstbytes)\n+ \n contentType, self._width, self._height = res\n+ \n+ if (self._width, self._height) == (-1, -1):\n+ # not enough information on firstbytes to guess width/height ?\n+ # TODO: missing problematic file on tests\n+ # see https://github.com/plone/plone.namedfile/pull/11\n+ contentType, self._width, self._height = getImageInfo(data)\n+\n if contentType:\n self.contentType = contentType\n \n@@ -428,8 +436,4 @@ def getFirstBytes(self, start=0, length=IMAGE_INFO_BYTES):\n \n def getImageSize(self):\n """See interface `IImage`"""\n- if (self._width, self._height) != (-1, -1):\n- return (self._width, self._height)\n-\n- contentType, self._width, self._height = getImageInfo(self.data)\n return (self._width, self._height)\n'

Repository: plone.namedfile


Branch: refs/heads/4.2.x
Date: 2019-05-30T20:47:06+02:00
Author: mauro (mamico) <mauro.amico@unibo.it>
Commit: https://github.com/plone/plone.namedfile/commit/db4478cce586535f5f184eb6ddf0e5793ad41836

changelog

Files changed:
M news/78.bugfix

b'diff --git a/news/78.bugfix b/news/78.bugfix\nindex e69de29..392890e 100644\n--- a/news/78.bugfix\n+++ b/news/78.bugfix\n@@ -0,0 +1,2 @@\n+fix multiple write during image requests\n+[mamico]\n\\ No newline at end of file\n'

Repository: plone.namedfile


Branch: refs/heads/4.2.x
Date: 2019-05-31T22:44:56+02:00
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at>
Commit: https://github.com/plone/plone.namedfile/commit/622730e35aab61af1bcadce1e8aed19677e85831

Merge pull request #78 from mamico/4.2.x-patch1

fix multiple write during image requests
Fixes #296
Closes plone/Products.CMFPlone#2881

Files changed:
A news/78.bugfix
M plone/namedfile/file.py
A news/296.bugfix
M plone/app/dexterity/browser/behaviors.py
M plone/app/dexterity/tests/editing.rst

b'diff --git a/news/78.bugfix b/news/78.bugfix\nnew file mode 100644\nindex 0000000..392890e\n--- /dev/null\n+++ b/news/78.bugfix\n@@ -0,0 +1,2 @@\n+fix multiple write during image requests\n+[mamico]\n\\ No newline at end of file\ndiff --git a/plone/namedfile/file.py b/plone/namedfile/file.py\nindex 1f63219..9b225b4 100644\n--- a/plone/namedfile/file.py\n+++ b/plone/namedfile/file.py\n@@ -409,7 +409,15 @@ def _setData(self, data):\n length = max(0, MAX_INFO_BYTES - start)\n firstbytes += self.getFirstBytes(start, length)\n res = getImageInfo(firstbytes)\n+ \n contentType, self._width, self._height = res\n+ \n+ if (self._width, self._height) == (-1, -1):\n+ # not enough information on firstbytes to guess width/height ?\n+ # TODO: missing problematic file on tests\n+ # see https://github.com/plone/plone.namedfile/pull/11\n+ contentType, self._width, self._height = getImageInfo(data)\n+\n if contentType:\n self.contentType = contentType\n \n@@ -428,8 +436,4 @@ def getFirstBytes(self, start=0, length=IMAGE_INFO_BYTES):\n \n def getImageSize(self):\n """See interface `IImage`"""\n- if (self._width, self._height) != (-1, -1):\n- return (self._width, self._height)\n-\n- contentType, self._width, self._height = getImageInfo(self.data)\n return (self._width, self._height)\n'
b'diff --git a/news/296.bugfix b/news/296.bugfix\nnew file mode 100644\nindex 0000000..be85e20\n--- /dev/null\n+++ b/news/296.bugfix\n@@ -0,0 +1 @@\n+The @@behaviors form was wrongly encoding the added behavior names on Python3 [ale-rt]\ndiff --git a/plone/app/dexterity/browser/behaviors.py b/plone/app/dexterity/browser/behaviors.py\nindex a76de50..739c651 100644\n--- a/plone/app/dexterity/browser/behaviors.py\n+++ b/plone/app/dexterity/browser/behaviors.py\n@@ -21,6 +21,23 @@\n import six\n \n \n+try:\n+ from Products.CMFPlone.utils import safe_nativestring\n+except ImportError:\n+ # Not needed for Products.CMFPlone >= 5.2a1\n+ from Products.CMFPlone.utils import safe_encode\n+ from Products.CMFPlone.utils import safe_unicode\n+\n+ def safe_nativestring(value, encoding=\'utf-8\'):\n+ """Convert a value to str in py2 and to text in py3\n+ """\n+ if six.PY2 and isinstance(value, six.text_type):\n+ value = safe_encode(value, encoding)\n+ if not six.PY2 and isinstance(value, six.binary_type):\n+ value = safe_unicode(value, encoding)\n+ return value\n+\n+\n TTW_BEHAVIOR_BLACKLIST = [\n # skip deprecated behavior\n \'plone.app.dexterity.behaviors.related.IRelatedItems\',\n@@ -53,14 +70,13 @@ def __setattr__(self, name, value):\n behaviors = list(self.fti.behaviors)\n reg = lookup_behavior_registration(name=name)\n iid = reg.interface.__identifier__\n-\n if reg.name:\n # behavior has a name -> use it\n # but first remove the dotted behavior if present\n if iid in self.fti.behaviors:\n behaviors.remove(iid)\n # prepare named behavior for add/remove\n- bname = reg.name.encode(\'utf8\')\n+ bname = safe_nativestring(reg.name)\n else:\n # no name found -> prepare dotted behavior for add/remove instead\n bname = iid\ndiff --git a/plone/app/dexterity/tests/editing.rst b/plone/app/dexterity/tests/editing.rst\nindex 8391cce..9955ba5 100644\n--- a/plone/app/dexterity/tests/editing.rst\n+++ b/plone/app/dexterity/tests/editing.rst\n@@ -264,6 +264,17 @@ FTI::\n >>> \'plone.namefromtitle\' in portal.portal_types.plonista.behaviors\n True\n \n+Let\'s enable one that is not enable and make sure that\n+the change is reflected on the FTI::\n+\n+ >>> sorted(portal.portal_types.plonista.behaviors)\n+ [\'plone.dublincore\', \'plone.namefromtitle\']\n+ >>> \'plone.versioning\' in portal.portal_types.plonista.behaviors\n+ False\n+ >>> browser.getControl(name=\'form.widgets.plone.versioning:list\').value = "selected"\n+ >>> browser.getControl(\'Save\').click()\n+ >>> sorted(portal.portal_types.plonista.behaviors)\n+ [\'plone.dublincore\', \'plone.namefromtitle\', \'plone.versioning\']\n \n Viewing a non-editable schema\n -----------------------------\n@@ -557,4 +568,3 @@ file::\n ...\n </schema>\n </model>\n-\n'

0 comments on commit 6e9bcf5

Please sign in to comment.