Skip to content

Commit

Permalink
[fc] Repository: plone.dexterity
Browse files Browse the repository at this point in the history
Branch: refs/heads/master
Date: 2018-10-02T10:36:04+02:00
Author: ale-rt (ale-rt) <[email protected]>
Commit: plone/plone.dexterity@f7dc782

Deal with the fact that email messages are native string on both Python versions

Files changed:
M CHANGES.rst
M plone/dexterity/filerepresentation.py
Repository: plone.dexterity

Branch: refs/heads/master
Date: 2018-10-02T13:30:48+02:00
Author: Jens W. Klein (jensens) <[email protected]>
Commit: plone/plone.dexterity@9c6792c

Merge pull request #90 from plone/fix-email-serialization

Deal with the fact that email messages are native string on both Pyth…

Files changed:
M CHANGES.rst
M plone/dexterity/filerepresentation.py
  • Loading branch information
jensens committed Oct 2, 2018
1 parent bd5a809 commit 00c05da
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
Repository: Products.CMFPlone
Repository: plone.dexterity


Branch: refs/heads/master
Date: 2018-10-02T13:28:57+02:00
Author: Maurits van Rees (mauritsvanrees) <[email protected]>
Commit: https://github.com/plone/Products.CMFPlone/commit/8afb8898c2cdfbc9d843fccf88c71e101dbbc4bb
Date: 2018-10-02T10:36:04+02:00
Author: ale-rt (ale-rt) <[email protected]>
Commit: https://github.com/plone/plone.dexterity/commit/f7dc782cc701ebe4707baf855b56eb1303d313b9

Removed the raiseUnauthorized skin script. (#2550)
Deal with the fact that email messages are native string on both Python versions

If you use this, please do permission checking in your own Python code instead (likely in a browser view).

Refs https://github.com/plone/Products.CMFPlone/issues/1801
Files changed:
M CHANGES.rst
M plone/dexterity/filerepresentation.py

b"diff --git a/CHANGES.rst b/CHANGES.rst\nindex 2f29ecd..187e60d 100644\n--- a/CHANGES.rst\n+++ b/CHANGES.rst\n@@ -17,7 +17,8 @@ New features:\n \n Bug fixes:\n \n-- *add item here*\n+- Other Python 3 compatibility fixes\n+ [ale-rt]\n \n \n 2.6.1 (2018-09-23)\ndiff --git a/plone/dexterity/filerepresentation.py b/plone/dexterity/filerepresentation.py\nindex d6c12e4..22e0c6f 100644\n--- a/plone/dexterity/filerepresentation.py\n+++ b/plone/dexterity/filerepresentation.py\n@@ -1,7 +1,8 @@\n # -*- coding: utf-8 -*-\n+from AccessControl import ClassSecurityInfo\n+from AccessControl.class_init import InitializeClass\n from Acquisition import aq_base\n from Acquisition import Implicit\n-from email.generator import Generator\n from email.message import Message\n from email.parser import FeedParser\n from plone.dexterity import bbb\n@@ -13,11 +14,11 @@\n from plone.rfc822 import constructMessageFromSchemata\n from plone.rfc822 import initializeObjectFromSchemata\n from plone.rfc822.interfaces import IPrimaryField\n+from Products.CMFCore import permissions\n from Products.CMFCore.utils import getToolByName\n from zExceptions import MethodNotAllowed\n from zExceptions import Unauthorized\n from zope.component import adapter\n-from zope.component import getAdapter\n from zope.component import createObject\n from zope.event import notify\n from zope.filerepresentation.interfaces import IDirectoryFactory\n@@ -26,15 +27,14 @@\n from zope.filerepresentation.interfaces import IRawWriteFile\n from zope.interface import implementer\n from zope.interface.interfaces import IInterface\n-from zope.lifecycleevent import modified, ObjectCreatedEvent\n+from zope.lifecycleevent import modified\n+from zope.lifecycleevent import ObjectCreatedEvent\n from zope.schema import getFieldsInOrder\n from zope.size.interfaces import ISized\n from ZPublisher.Iterators import IStreamIterator\n-import tempfile\n \n-from AccessControl.class_init import InitializeClass\n-from AccessControl import ClassSecurityInfo\n-from Products.CMFCore import permissions\n+import six\n+import tempfile\n \n if bbb.HAS_ZSERVER:\n from webdav.Resource import Resource\n@@ -687,9 +687,14 @@ def _getStream(self):\n # this approach allows us to hand off the stream iterator to the\n # publisher, which will serve it efficiently even after the\n # transaction is closed\n- out = tempfile.TemporaryFile(mode='w+b')\n- generator = Generator(out, mangle_from_=False)\n- generator.flatten(self._getMessage())\n+ message = self._getMessage()\n+ if six.PY2:\n+ # message.as_string will return str in both Python 2 and 3\n+ mode = 'w+b'\n+ else:\n+ mode = 'w+'\n+ out = tempfile.TemporaryFile(mode=mode)\n+ out.write(message.as_string())\n self._size = out.tell()\n out.seek(0)\n return out\n"

Repository: plone.dexterity


Branch: refs/heads/master
Date: 2018-10-02T13:30:48+02:00
Author: Jens W. Klein (jensens) <[email protected]>
Commit: https://github.com/plone/plone.dexterity/commit/9c6792c677763e3dab02abd4c70807739b70d251

Merge pull request #90 from plone/fix-email-serialization

Deal with the fact that email messages are native string on both Pyth…

Files changed:
M CHANGES.rst
D Products/CMFPlone/skins/plone_scripts/raiseUnauthorized.py
M plone/dexterity/filerepresentation.py

b'diff --git a/CHANGES.rst b/CHANGES.rst\nindex 65ab55379..f27a3338d 100644\n--- a/CHANGES.rst\n+++ b/CHANGES.rst\n@@ -40,6 +40,11 @@ New features:\n \n Bug fixes:\n \n+- Removed the ``raiseUnauthorized`` skin script.\n+ If you use this, please do permission checking in your own Python code instead (likely in a browser view).\n+ Refs `issue 1801 <https://github.com/plone/Products.CMFPlone/issues/1801>`_.\n+ [maurits]\n+\n - Remove the devdependencies from bower.json - they are just used for running tests in mockup, not here.\n [sunew]\n \ndiff --git a/Products/CMFPlone/skins/plone_scripts/raiseUnauthorized.py b/Products/CMFPlone/skins/plone_scripts/raiseUnauthorized.py\ndeleted file mode 100644\nindex b636da9ee..000000000\n--- a/Products/CMFPlone/skins/plone_scripts/raiseUnauthorized.py\n+++ /dev/null\n@@ -1,12 +0,0 @@\n-## Script (Python) "raiseUnauthorized"\n-##bind container=container\n-##bind context=context\n-##bind namespace=\n-##bind script=script\n-##bind subpath=traverse_subpath\n-##parameters=\n-##title=\n-\n-from AccessControl import Unauthorized\n-\n-raise Unauthorized\n'
b"diff --git a/CHANGES.rst b/CHANGES.rst\nindex 2f29ecd..187e60d 100644\n--- a/CHANGES.rst\n+++ b/CHANGES.rst\n@@ -17,7 +17,8 @@ New features:\n \n Bug fixes:\n \n-- *add item here*\n+- Other Python 3 compatibility fixes\n+ [ale-rt]\n \n \n 2.6.1 (2018-09-23)\ndiff --git a/plone/dexterity/filerepresentation.py b/plone/dexterity/filerepresentation.py\nindex d6c12e4..22e0c6f 100644\n--- a/plone/dexterity/filerepresentation.py\n+++ b/plone/dexterity/filerepresentation.py\n@@ -1,7 +1,8 @@\n # -*- coding: utf-8 -*-\n+from AccessControl import ClassSecurityInfo\n+from AccessControl.class_init import InitializeClass\n from Acquisition import aq_base\n from Acquisition import Implicit\n-from email.generator import Generator\n from email.message import Message\n from email.parser import FeedParser\n from plone.dexterity import bbb\n@@ -13,11 +14,11 @@\n from plone.rfc822 import constructMessageFromSchemata\n from plone.rfc822 import initializeObjectFromSchemata\n from plone.rfc822.interfaces import IPrimaryField\n+from Products.CMFCore import permissions\n from Products.CMFCore.utils import getToolByName\n from zExceptions import MethodNotAllowed\n from zExceptions import Unauthorized\n from zope.component import adapter\n-from zope.component import getAdapter\n from zope.component import createObject\n from zope.event import notify\n from zope.filerepresentation.interfaces import IDirectoryFactory\n@@ -26,15 +27,14 @@\n from zope.filerepresentation.interfaces import IRawWriteFile\n from zope.interface import implementer\n from zope.interface.interfaces import IInterface\n-from zope.lifecycleevent import modified, ObjectCreatedEvent\n+from zope.lifecycleevent import modified\n+from zope.lifecycleevent import ObjectCreatedEvent\n from zope.schema import getFieldsInOrder\n from zope.size.interfaces import ISized\n from ZPublisher.Iterators import IStreamIterator\n-import tempfile\n \n-from AccessControl.class_init import InitializeClass\n-from AccessControl import ClassSecurityInfo\n-from Products.CMFCore import permissions\n+import six\n+import tempfile\n \n if bbb.HAS_ZSERVER:\n from webdav.Resource import Resource\n@@ -687,9 +687,14 @@ def _getStream(self):\n # this approach allows us to hand off the stream iterator to the\n # publisher, which will serve it efficiently even after the\n # transaction is closed\n- out = tempfile.TemporaryFile(mode='w+b')\n- generator = Generator(out, mangle_from_=False)\n- generator.flatten(self._getMessage())\n+ message = self._getMessage()\n+ if six.PY2:\n+ # message.as_string will return str in both Python 2 and 3\n+ mode = 'w+b'\n+ else:\n+ mode = 'w+'\n+ out = tempfile.TemporaryFile(mode=mode)\n+ out.write(message.as_string())\n self._size = out.tell()\n out.seek(0)\n return out\n"

0 comments on commit 00c05da

Please sign in to comment.