From 47340d1c68e5c0191edc6cb9c297a5589ea29f1e Mon Sep 17 00:00:00 2001 From: zhang-liang-pengkun Date: Fri, 19 Jan 2024 16:17:48 +0800 Subject: [PATCH] Add ServerAdapter for CherryPy >= 9 Signed-off-by: zhang-liang-pengkun --- 0010-Add-ServerAdapter-for-CherryPy-9.patch | 46 +++++++++++++++++++++ python-bottle.spec | 6 ++- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 0010-Add-ServerAdapter-for-CherryPy-9.patch diff --git a/0010-Add-ServerAdapter-for-CherryPy-9.patch b/0010-Add-ServerAdapter-for-CherryPy-9.patch new file mode 100644 index 0000000..21e86db --- /dev/null +++ b/0010-Add-ServerAdapter-for-CherryPy-9.patch @@ -0,0 +1,46 @@ +From 888aa8e7b8f6490015463ee370ff4026fc951b1f Mon Sep 17 00:00:00 2001 +From: 06180339 +Date: Sat, 28 Jan 2017 23:29:29 +0100 +Subject: [PATCH] Add ServerAdapter for CherryPy >= 9 + +Since CherryPy >= 9, the server part of CherryPy has been extracted and named Cheroot. Thus the old CherryPy ServerAdapter does not work for CherryPy >= 9: the import fails, and the SSL part should be different too. Cheroot can be installed (git install cheroot) without CherryPy so that we can just have a CherootServer adapter in addition to the CherryPyServer adapter for the older versions. + +(cherry picked from commit b9229eef97ea246e3d0e0c455071d54435a1557d) +Signed-off-by: Juerg Haefliger +--- + bottle.py | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +diff --git a/bottle.py b/bottle.py +index 04ccf7d..73886a2 100644 +--- a/bottle.py ++++ b/bottle.py +@@ -2816,6 +2816,25 @@ class CherryPyServer(ServerAdapter): + server.stop() + + ++class CherootServer(ServerAdapter): ++ def run(self, handler): # pragma: no cover ++ from cheroot import wsgi ++ from cheroot.ssl import builtin ++ self.options['bind_addr'] = (self.host, self.port) ++ self.options['wsgi_app'] = handler ++ certfile = self.options.pop('certfile', None) ++ keyfile = self.options.pop('keyfile', None) ++ chainfile = self.options.pop('chainfile', None) ++ server = wsgi.Server(**self.options) ++ if certfile and keyfile: ++ server.ssl_adapter = builtin.BuiltinSSLAdapter( ++ certfile, keyfile, chainfile) ++ try: ++ server.start() ++ finally: ++ server.stop() ++ ++ + class WaitressServer(ServerAdapter): + def run(self, handler): + from waitress import serve +-- +2.39.0.windows.2 + diff --git a/python-bottle.spec b/python-bottle.spec index 7c5b6a0..dd460cf 100644 --- a/python-bottle.spec +++ b/python-bottle.spec @@ -1,6 +1,6 @@ Name: python-bottle Version: 0.12.13 -Release: 19 +Release: 20 Summary: WSGI micro web-framework for Python. License: MIT URL: https://github.com/bottlepy/bottle @@ -17,6 +17,7 @@ Patch0007: 0006-1177-Bug-fix-of-missing-regex-escaped-back-slashes.patch Patch0008: 0007-Fix-the-Allow-header-value-in-405-Method-not-allowed.patch Patch0009: 0008-Fix-Multipart-file-uploads-with-empty-filename-not-d.patch Patch0010: 0009-auth-basic-decorator-doesnt-use-functools-wraps.patch +Patch0011: 0010-Add-ServerAdapter-for-CherryPy-9.patch BuildArch: noarch BuildRequires: python3-devel python3-setuptools @@ -54,6 +55,9 @@ sed -i '/^#!/d' bottle.py %exclude %{_bindir}/bottle.py %changelog +* Fri Jan 19 2024 zhangliangpengkun - 0.12.13-20 +- Add ServerAdapter for CherryPy >= 9 + * Thu Jan 18 2024 zhangliangpengkun - 0.12.13-19 - The auth_basic() decorator doesn't use functools.wraps(). -- Gitee