!83 Add ServerAdapter for CherryPy >= 9

From: @zhang-liang-pengkun 
Reviewed-by: @Charlie_li 
Signed-off-by: @Charlie_li
This commit is contained in:
openeuler-ci-bot 2024-01-19 03:34:25 +00:00 committed by Gitee
commit 06b639717a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 51 additions and 1 deletions

View File

@ -0,0 +1,46 @@
From 888aa8e7b8f6490015463ee370ff4026fc951b1f Mon Sep 17 00:00:00 2001
From: 06180339 <mlrst@web.de>
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 <juergh@protonmail.com>
---
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

View File

@ -1,6 +1,6 @@
Name: python-bottle Name: python-bottle
Version: 0.12.13 Version: 0.12.13
Release: 18 Release: 19
Summary: WSGI micro web-framework for Python. Summary: WSGI micro web-framework for Python.
License: MIT License: MIT
URL: http://bottlepy.org URL: http://bottlepy.org
@ -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 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 Patch0009: 0008-Fix-Multipart-file-uploads-with-empty-filename-not-d.patch
Patch0010: 0009-Fix-for-Issue-586.patch Patch0010: 0009-Fix-for-Issue-586.patch
Patch0011: 0010-Add-ServerAdapter-for-CherryPy-9.patch
BuildArch: noarch BuildArch: noarch
BuildRequires: python2-devel python2-setuptools python3-devel python3-setuptools BuildRequires: python2-devel python2-setuptools python3-devel python3-setuptools
@ -71,6 +72,9 @@ sed -i '/^#!/d' bottle.py
%{python3_sitelib}/* %{python3_sitelib}/*
%changelog %changelog
* Thu Jan 18 2024 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 0.12.13-19
- Add ServerAdapter for CherryPy >= 9
* Fri Jan 12 2024 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 0.12.13-18 * Fri Jan 12 2024 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 0.12.13-18
- The auth_basic() decorator doesn't use functools.wraps(). - The auth_basic() decorator doesn't use functools.wraps().