Commit a7e370de authored by Jérome Perrin's avatar Jérome Perrin

stack/erp5: version up Zope stack ( 4.8.2 + upcoming patches from 4.x )

parent 44f611ce
From d3885eadb919abfcc86a82431deb9b9916127602 Mon Sep 17 00:00:00 2001
From: dieter <dieter@handshake.de>
Date: Wed, 2 Mar 2022 08:31:58 +0100
Subject: [PATCH] fix `OFS.Image.File.PUT` -- Issue 1015
work around `cgi` bug
make `flake8` happy
---
src/OFS/Image.py | 47 ++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 44 insertions(+), 3 deletions(-)
diff --git a/src/OFS/Image.py b/src/OFS/Image.py
index c7b012a5e..fde006deb 100644
--- a/src/OFS/Image.py
+++ b/src/OFS/Image.py
@@ -16,6 +16,8 @@
import struct
from email.generator import _make_boundary
from io import BytesIO
+from io import TextIOBase
+from tempfile import TemporaryFile
from warnings import warn
from six import PY2
@@ -568,6 +570,16 @@ class File(
self, REQUEST, manage_tabs_message=msg)
def _get_content_type(self, file, body, id, content_type=None):
+ """return content type or ``None``.
+
+ *file* usually is a ``FileUpload`` (like) instance; if this
+ specifies a content type, it is used. If *file*
+ is not ``FileUpload`` like, it is ignored and the
+ content type is guessed from the other parameters.
+
+ *body* is either a ``bytes`` or a ``Pdata`` instance
+ and assumed to be the *file* data.
+ """
headers = getattr(file, 'headers', None)
if headers and 'content-type' in headers:
content_type = headers['content-type']
@@ -579,6 +591,13 @@ class File(
return content_type
def _read_data(self, file):
+ """return the data and size of *file* as tuple *data*, *size*.
+
+ *file* can be a ``bytes``, ``Pdata``, ``FileUpload`` or
+ (binary) file like instance.
+
+ For large files, *data* is a ``Pdata``, otherwise a ``bytes`` instance.
+ """
import transaction
n = 1 << 16
@@ -656,13 +675,35 @@ class File(
"""Handle HTTP PUT requests"""
self.dav__init(REQUEST, RESPONSE)
self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1)
- type = REQUEST.get_header('content-type', None)
+ type = REQUEST.get_header('content-type', None)
file = REQUEST['BODYFILE']
+ # Work around ``cgi`` bug
+ # ``cgi`` can turn the request body into a text file using
+ # the default encoding. ``File``, however, insists to work
+ # with bytes and binary files and forbids text.
+ # Convert back.
+ tfile = None
+ if isinstance(file, TextIOBase): # ``cgi`` bug
+ if hasattr(file, "buffer"):
+ file = file.buffer # underlying binary buffer
+ else:
+ from ZPublisher.HTTPRequest import default_encoding
+ tfile = TemporaryFile("wb+")
+ bufsize = 1 << 16
+ while True:
+ data = file.read(bufsize)
+ if not data:
+ break
+ tfile.write(data.encode(default_encoding))
+ file.seek(0, 0)
+ tfile.seek(0, 0)
+ file = tfile
+
data, size = self._read_data(file)
- if isinstance(data, str):
- data = data.encode('UTF-8')
+ if tfile is not None:
+ tfile.close()
content_type = self._get_content_type(file, data, self.__name__,
type or self.content_type)
self.update_data(data, content_type, size)
--
2.35.1
...@@ -835,10 +835,7 @@ class ZopeTestMixin(ZopeSkinsMixin, CrontabMixin): ...@@ -835,10 +835,7 @@ class ZopeTestMixin(ZopeSkinsMixin, CrontabMixin):
class TestZopeWSGI(ZopeTestMixin, ERP5InstanceTestCase): class TestZopeWSGI(ZopeTestMixin, ERP5InstanceTestCase):
pass
@unittest.expectedFailure
def test_basic_authentication_user_in_access_log(self):
super().test_basic_authentication_user_in_access_log()
class TestZopePublisherTimeout(ZopeSkinsMixin, ERP5InstanceTestCase): class TestZopePublisherTimeout(ZopeSkinsMixin, ERP5InstanceTestCase):
......
[buildout] [buildout]
extends = extends =
# Exact version of Zope # versions pins from zope, vendored with
# curl https://zopefoundation.github.io/Zope/releases/4.8.2/versions.cfg | sed -e s/versions-prod.cfg/zope-versions.cfg/g > ztk-versions.cfg
# curl https://zopefoundation.github.io/Zope/releases/4.8.2/versions-prod.cfg > zope-versions.cfg
ztk-versions.cfg ztk-versions.cfg
zope-versions.cfg zope-versions.cfg
buildout.hash.cfg buildout.hash.cfg
...@@ -546,7 +548,6 @@ eggs = ${neoppod:eggs} ...@@ -546,7 +548,6 @@ eggs = ${neoppod:eggs}
${Products.CMFCore:egg} ${Products.CMFCore:egg}
${Products.DCWorkflow:egg} ${Products.DCWorkflow:egg}
${Products.GenericSetup:egg} ${Products.GenericSetup:egg}
five.localsitemanager
# Other products # Other products
Products.MimetypesRegistry Products.MimetypesRegistry
...@@ -632,7 +633,9 @@ python-magic-patches = ${:_profile_base_location_}/../../component/egg-patch/pyt ...@@ -632,7 +633,9 @@ python-magic-patches = ${:_profile_base_location_}/../../component/egg-patch/pyt
python-magic-patch-options = -p1 python-magic-patch-options = -p1
# Zope 4 patches # Zope 4 patches
Zope-patches = Zope-patches =
${:_profile_base_location_}/../../component/egg-patch/Zope/0001-fix-OFS.Image.File.PUT-Issue-1015.patch#c706e2f572ad8cd37ed033fb5f873cbe https://github.com/zopefoundation/Zope/commit/ce59c3266cdd19fdb8a7456fd55b3385d50a4ab0.patch#33be66d71933c5d35b5c238e44cef160
https://github.com/zopefoundation/Zope/commit/337bc76e0695f09fca97527514bcf29c104e33b8.patch#d6d55cf47754dcdf8022adcf11d3f1f6
https://github.com/zopefoundation/Zope/commit/68f0c122cf938c3e6184185cd8519e26ff7d0b14.patch#5a2c9c31caaaba75677507ddb3a0becc
Zope-patch-options = -p1 Zope-patch-options = -p1
[eggs-all-scripts] [eggs-all-scripts]
...@@ -679,16 +682,12 @@ pysvn = 1.9.15+SlapOSPatched001 ...@@ -679,16 +682,12 @@ pysvn = 1.9.15+SlapOSPatched001
python-ldap = 2.4.32+SlapOSPatched001 python-ldap = 2.4.32+SlapOSPatched001
python-magic = 0.4.12+SlapOSPatched001 python-magic = 0.4.12+SlapOSPatched001
PyPDF2 = 1.26.0+SlapOSPatched001 PyPDF2 = 1.26.0+SlapOSPatched001
Zope = 4.5.3+SlapOSPatched001 Zope = 4.8.2+SlapOSPatched003
## https://lab.nexedi.com/nexedi/slapos/merge_requests/648 ## https://lab.nexedi.com/nexedi/slapos/merge_requests/648
pylint = 1.4.4+SlapOSPatched002 pylint = 1.4.4+SlapOSPatched002
# astroid 1.4.1 breaks testDynamicClassGeneration # astroid 1.4.1 breaks testDynamicClassGeneration
astroid = 1.3.8+SlapOSPatched001 astroid = 1.3.8+SlapOSPatched001
# use newer version than specified in ZTK
PasteDeploy = 1.5.2
argparse = 1.4.0 argparse = 1.4.0
zope.dottedname = 4.1.0
# modified version that works fine for buildout installation # modified version that works fine for buildout installation
SOAPpy = 0.12.0nxd001 SOAPpy = 0.12.0nxd001
...@@ -722,7 +721,6 @@ StructuredText = 2.11.1 ...@@ -722,7 +721,6 @@ StructuredText = 2.11.1
WSGIUtils = 0.7 WSGIUtils = 0.7
erp5diff = 0.8.1.8 erp5diff = 0.8.1.8
five.formlib = 1.0.4 five.formlib = 1.0.4
five.localsitemanager = 2.0.5
google-api-python-client = 1.6.1 google-api-python-client = 1.6.1
httplib2 = 0.10.3 httplib2 = 0.10.3
huBarcode = 1.0.0 huBarcode = 1.0.0
...@@ -806,23 +804,24 @@ jsonpointer = 2.2 ...@@ -806,23 +804,24 @@ jsonpointer = 2.2
# WIP Zope 4 ⚠ # WIP Zope 4 ⚠
zope.interface = 5.2.0 Products.CMFCore = 2.6.0
ZConfig = 3.5.0
Products.CMFCore = 2.5.4
Products.StandardCacheManagers = 4.1.0 Products.StandardCacheManagers = 4.1.0
Products.ExternalMethod = 4.5 Products.ExternalMethod = 4.5
Products.GenericSetup = 2.1.5 Products.GenericSetup = 2.1.5
Products.PythonScripts = 4.13 Products.PythonScripts = 4.13
Products.MailHost = 4.11 Products.MailHost = 4.11
Products.Sessions = 4.12 Products.Sessions = 4.14
Products.SiteErrorLog = 5.5 Products.SiteErrorLog = 5.6
Products.ZSQLMethods = 3.14 Products.ZSQLMethods = 3.14
Products.ZODBMountPoint = 1.2 Products.ZODBMountPoint = 1.2
html5lib = 1.1 html5lib = 1.1
mechanize = 0.4.7
zLOG = 3.1 zLOG = 3.1
zope.password = 4.3.1 zope.password = 4.4
zope.error = 4.5.0 zope.error = 4.6
zope.authentication = 4.5.0 zope.authentication = 4.5.0
zope.session = 4.4.0 zope.session = 4.5
zope.minmax = 2.2.0 zope.minmax = 2.3
# XXX do we need ?
mechanize = 0.4.8
webencodings = 0.5.1
[buildout]
# Version pins for required and commonly used dependencies.
[versions] [versions]
#Zope = 4.5.3 Zope = 4.8.2
Zope2 = 4.0 Zope2 = 4.0
# AccessControl 5+ no longer supports Zope 4. # AccessControl 5+ no longer supports Zope 4.
AccessControl = 4.2 AccessControl = 4.3
Acquisition = 4.7 Acquisition = 4.10
AuthEncoding = 4.2 AuthEncoding = 4.3
BTrees = 4.7.2 BTrees = 4.10.0
Chameleon = 3.8.1 Chameleon = 3.9.1
DateTime = 4.3 DateTime = 4.4
# DocumentTemplate 4+ no longer supports Zope 4. DocumentTemplate = 4
DocumentTemplate = 3.4 ExtensionClass = 4.6
ExtensionClass = 4.5.0
Missing = 4.1 Missing = 4.1
MultiMapping = 4.1 MultiMapping = 4.1
Paste = 3.5.0 Paste = 3.5.0
PasteDeploy = 2.1.1 PasteDeploy = 2.1.1
Persistence = 3.0 Persistence = 3.3
Products.BTreeFolder2 = 4.2 Products.BTreeFolder2 = 4.3
# ZCatalog 6+ no longer supports Zope 4. # ZCatalog 6+ no longer supports Zope 4.
Products.ZCatalog = 5.2 Products.ZCatalog = 5.4
Record = 3.5 Record = 3.5
RestrictedPython = 5.1 RestrictedPython = 5.2
WSGIProxy2 = 0.4.6 WSGIProxy2 = 0.5.1
WebOb = 1.8.6 WebOb = 1.8.7
WebTest = 2.0.35 WebTest = 3.0.0
ZConfig = 3.5.0 ZConfig = 3.6.0
ZEO = 5.2.2 ZEO = 5.3.0
ZODB = 5.6.0 ZODB = 5.7.0
ZServer = 4.0.2
five.globalrequest = 99.1 five.globalrequest = 99.1
five.localsitemanager = 3.2.2 five.localsitemanager = 3.2.2
funcsigs = 1.0.2 funcsigs = 1.0.2
future = 0.18.2 future = 0.18.2
ipaddress = 1.0.23 ipaddress = 1.0.23
# mock 4.0 and up requires Python 3 mock = 4.0.3
mock = 3.0.5 multipart = 0.2.4
pbr = 5.5.1 pbr = 5.8.1
persistent = 4.6.4 persistent = 4.9.0
pytz = 2020.4 pytz = 2022.1
roman = 3.3 roman = 3.3
shutilwhich = 1.1.0 shutilwhich = 1.1.0
six = 1.15.0 six = 1.16.0
transaction = 3.0.0 transaction = 3.0.1
waitress = 1.4.4 waitress = 2.1.2
z3c.pt = 3.3.0 z3c.pt = 3.3.1
zExceptions = 4.1 zExceptions = 4.2
zc.lockfile = 2.0 zc.lockfile = 2.0
zdaemon = 4.3 zdaemon = 4.3
zodbpickle = 2.0.0 zodbpickle = 2.2.0
zope.annotation = 4.7.0 zope.annotation = 4.7.0
zope.browser = 2.3 zope.browser = 2.3
zope.browsermenu = 4.4 zope.browsermenu = 4.4
zope.browserpage = 4.4.0 zope.browserpage = 4.4.0
zope.browserresource = 4.4 zope.browserresource = 4.4
zope.cachedescriptors = 4.3.1 zope.cachedescriptors = 4.3.1
zope.component = 4.6.2 zope.component = 5.0.1
zope.componentvocabulary = 2.2.0 zope.componentvocabulary = 2.3.0
zope.configuration = 4.4.0 zope.configuration = 4.4.0
zope.container = 4.4.0 zope.container = 4.5.0
zope.contentprovider = 4.2.1 zope.contentprovider = 4.2.1
zope.contenttype = 4.5.0 zope.contenttype = 4.5.0
zope.datetime = 4.2.0 zope.datetime = 4.3.0
zope.deferredimport = 4.3.1 zope.deferredimport = 4.4
zope.deprecation = 4.4.0 zope.deprecation = 4.4.0
zope.dottedname = 4.3 zope.dottedname = 4.3
zope.event = 4.5.0 zope.event = 4.5.0
zope.exceptions = 4.4 zope.exceptions = 4.5
zope.filerepresentation = 5.0.0 zope.filerepresentation = 5.0.0
zope.formlib = 4.7.1 zope.formlib = 5.0.1
zope.globalrequest = 1.5 zope.globalrequest = 1.5
zope.hookable = 5.0.1 zope.hookable = 5.1.0
zope.i18n = 4.7.0 zope.i18n = 4.9.0
zope.i18nmessageid = 5.0.1 zope.i18nmessageid = 5.0.1
zope.interface = 5.2.0 zope.interface = 5.4.0
zope.lifecycleevent = 4.3.0 zope.lifecycleevent = 4.3.0
zope.location = 4.2 zope.location = 4.2
zope.pagetemplate = 4.5.0 zope.pagetemplate = 4.6.0
zope.processlifetime = 2.3.0 zope.processlifetime = 2.3.0
zope.proxy = 4.3.5 zope.proxy = 4.5.0
zope.ptresource = 4.2.0 zope.ptresource = 4.3.0
zope.publisher = 5.2.1 zope.publisher = 6.1.0
zope.ramcache = 2.3 zope.ramcache = 2.4
zope.schema = 6.0.0 zope.schema = 6.2.0
zope.security = 5.1.1 zope.security = 5.2
zope.sendmail = 5.1 zope.sendmail = 5.2
zope.sequencesort = 4.1.2 zope.sequencesort = 4.2
zope.site = 4.4.0 zope.site = 4.5.0
zope.size = 4.3 zope.size = 4.3
zope.structuredtext = 4.3 zope.structuredtext = 4.4
zope.tal = 4.4 zope.tal = 4.5
zope.tales = 5.1 zope.tales = 5.1
zope.testbrowser = 5.5.1 zope.testbrowser = 5.6.1
# Version 4.8+ dropped support for Python 3.5 zope.testing = 4.10
zope.testing = 4.7 zope.testrunner = 5.4.0
zope.testrunner = 5.2
zope.traversing = 4.4.1 zope.traversing = 4.4.1
zope.viewlet = 4.2.1 zope.viewlet = 4.3
[versions:python27]
# DocumentTemplate 4+ requires Python 3.5 or higher
DocumentTemplate = 3.4
# WSGIProxy 0.5 and up requires Python 3.7 and up
WSGIProxy2 = 0.4.6
# WebTest 3.0 and up requires Python 3.6 and up
WebTest = 2.0.35
# ZServer is only available for Python 2
ZServer = 4.0.2
# mock 4.0 and up requires Python 3.6 or higher
mock = 3.0.5
# multipart 0.2 and up requires Python 3
multipart = 0.1.1
# waitress 2 requires Python 3.6 or higher
waitress = 1.4.4
[versions:python35]
# DocumentTemplate 4+ cannot be installed on Zope 4 for Python 3.5
DocumentTemplate = 3.4
# WSGIProxy 0.5 and up requires Python 3.7 and up
WSGIProxy2 = 0.4.6
# WebTest 3.0 and up requires Python 3.6 and up
WebTest = 2.0.35
# mock 4.0 and up requires Python 3.6 or higher
mock = 3.0.5
# waitress 2 requires Python 3.6 or higher
waitress = 1.4.4
[versions:python36]
# WSGIProxy 0.5 and up requires Python 3.7 and up
WSGIProxy2 = 0.4.6
# waitress 2.1 requires Python 3.7 or higher
waitress = 2.0.0
...@@ -5,84 +5,95 @@ versions = versions ...@@ -5,84 +5,95 @@ versions = versions
[versions] [versions]
# Version pins for development and optional dependencies. # Version pins for development and optional dependencies.
Babel = 2.8.1 Babel = 2.9.1
Jinja2 = 2.11.2 Jinja2 = 3.1.1
MarkupSafe = 2.1.1
Pygments = 2.11.2
Sphinx = 4.5.0
alabaster = 0.7.12
backports.functools-lru-cache = 1.6.4
beautifulsoup4 = 4.11.1
certifi = 2021.10.8
cffi = 1.15.0
chardet = 4.0.0
charset-normalizer = 2.0.4
collective.recipe.template = 2.2
# sphinx-rtd-theme requires docutils <18
docutils = 0.17.1
idna = 3.3
imagesize = 1.3.0
mr.developer = 2.0.1
packaging = 21.3
plone.recipe.command = 1.1
pyparsing = 3.0.8
pycparser = 2.21
python-gettext = 4.0
requests = 2.27.1
singledispatch = 3.7.0
snowballstemmer = 2.2.0
soupsieve = 2.3.2
sphinx-rtd-theme = 1.0.0
sphinxcontrib-applehelp = 1.0.2
sphinxcontrib-devhelp = 1.0.2
sphinxcontrib-htmlhelp = 2.0.0
sphinxcontrib-jsmath = 1.0.1
sphinxcontrib-qthelp = 1.0.3
sphinxcontrib-serializinghtml = 1.1.5
sphinxcontrib-websupport = 1.2.4
# tempstorage is only needed because the Sphinx documentation parses
# ZConfig xml configurations, which still contain references to it
tempstorage = 5.2
typing = 3.10.0.0
urllib3 = 1.26.9
z3c.checkversions = 1.2
zc.recipe.egg = 2.0.7
zc.recipe.testrunner = 2.2
zodbupdate = 1.5
[versions:python27]
# Jinja2 3 and up needs Python 3.6 or higher
Jinja2 = 2.11.3
# MarkupSafe 2+ needs Python 3.6 or higher
MarkupSafe = 1.1.1 MarkupSafe = 1.1.1
# Pygments 2.6.0 and up require Python 3 # Pygments 2.6.0 and up require Python 3
Pygments = 2.5.2 Pygments = 2.5.2
# Version 2.0+ needs Python 3.x # Version 2.0+ needs Python 3.x
Sphinx = 1.8.5 Sphinx = 1.8.5
alabaster = 0.7.12 # beautifulsoup4 4.10 and up requires Python 3
appdirs = 1.4.4
attrs = 20.3.0
backports.functools-lru-cache = 1.6.1
beautifulsoup4 = 4.9.3 beautifulsoup4 = 4.9.3
bleach = 3.2.1
buildout.wheel = 0.2.0
# Version 2020.4.5.2 and up claim no Python 2 support # Version 2020.4.5.2 and up claim no Python 2 support
certifi = 2020.4.5.1 certifi = 2020.4.5.1
cffi = 1.14.3 # idna 3 and up require Python 3
chardet = 3.0.4
cmarkgfm = 0.4.2
collective.recipe.cmd = 0.11
collective.recipe.sphinxbuilder = 1.1
collective.recipe.template = 2.1
colorama = 0.4.4
# configparser 5 and up require Python 3
configparser = 4.0.2
contextlib2 = 0.6.0.post1
coverage = 5.3
distlib = 0.3.1
docutils = 0.16
filelock = 3.0.12
idna = 2.10 idna = 2.10
imagesize = 1.2.0 # packaging 21 and up requires Python 3.6
# tox and pluggy require importlib-metadata <1 packaging = 20.9
importlib-metadata = 0.23 # pip 21 and up require Python 3
lxml = 4.6.1 pip = 20.3.4
manuel = 1.10.1 # pyparsing 3 and up require Python 3.6
# Version 6+ needs Python 3.x
more-itertools = 5.0.0
mr.developer = 2.0.1
nose = 1.3.7
packaging = 20.4
pathlib2 = 2.3.5
pip = 20.2.4
pkginfo = 1.6.1
plone.recipe.command = 1.1
pluggy = 0.13.1
py = 1.9.0
pycparser = 2.20
pyparsing = 2.4.7 pyparsing = 2.4.7
python-gettext = 4.0
readme-renderer = 28.0
repoze.sphinx.autointerface = 0.8
requests = 2.25.0
requests-toolbelt = 0.9.1
scandir = 1.10.0
snowballstemmer = 2.0.0
# soupsieve 2 needs Python 3 # soupsieve 2 needs Python 3
soupsieve = 1.9.6 soupsieve = 1.9.6
sphinx-rtd-theme = 0.5.0
sphinxcontrib-serializinghtml = 1.1.4 [versions:python35]
sphinxcontrib-websupport = 1.2.4 # Jinja2 3 and up needs Python 3.6 or higher
# tempstorage is only needed because the Sphinx documentation parses Jinja2 = 2.11.3
# ZConfig xml configurations, which still contain references to it # MarkupSafe 2+ needs Python 3.6 or higher
tempstorage = 5.1 MarkupSafe = 1.1.1
toml = 0.10.2 # Version 4 needs Python 3.6 or higher
tox = 3.20.1 Sphinx = 3.5.4
tqdm = 4.51.0 # beautifulsoup4 4.11 and up requires Python 3.6
# Version 2+ needs Python 3.x beautifulsoup4 = 4.10.0
twine = 1.15.0 # cffi 1.15 dropped support for Python 3.5
typing = 3.7.4.3 cffi = 1.14.6
urllib3 = 1.26.1 # packaging 21 and up requires Python 3.6
virtualenv = 20.1.0 packaging = 20.9
webencodings = 0.5.1 # pyparsing 3 and up require Python 3.6
wheel = 0.35.1 pyparsing = 2.4.7
z3c.checkversions = 1.2 # soupsieve 2.2 needs Python 3.6
zc.recipe.egg = 2.0.7 soupsieve = 2.1
zc.recipe.testrunner = 2.1
zest.releaser = 6.22.1 [versions:python36]
# Version 2 requires Python 3 # Jinja2 3.1 and up needs Python 3.7 or higher
zipp = 1.1.1 Jinja2 = 3.0.3
zodbupdate = 1.5 # MarkupSafe 2.1 needs Python 3.7 or higher
MarkupSafe = 2.0.1
...@@ -142,7 +142,8 @@ Importing = 1.10 ...@@ -142,7 +142,8 @@ Importing = 1.10
MarkupSafe = 2.0.1 MarkupSafe = 2.0.1
PyYAML = 5.4.1 PyYAML = 5.4.1
Werkzeug = 2.0.2 Werkzeug = 2.0.2
ZConfig = 2.9.3 # XXX Zope4 this ZConfig version seems misplaced (how about having it in ZODB ?)
ZConfig = 3.6.0
asn1crypto = 1.3.0 asn1crypto = 1.3.0
atomicwrites = 1.4.0 atomicwrites = 1.4.0
backports.functools-lru-cache = 1.6.1:whl backports.functools-lru-cache = 1.6.1:whl
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment