forked from pool/python-pecan
- update to 1.4.1:
* add support for Python 3.10 * added trove classifiers for Python 3.6 - 3.9 * fixed a bug related to setuptools as a dependency * fixed a bug that broke pecan when used with certain versions of SQLAlchemy - drop 0001-Support-SQLAlchemy-1.4.x.patch, 0002-Fix-typo-from-bad-copy-paste.patch: obsolete (upstream) OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pecan?expand=0&rev=60
This commit is contained in:
@@ -1,114 +0,0 @@
|
||||
From a89d425c183ea6fa3d1ad86c2f7bc8b0acf63323 Mon Sep 17 00:00:00 2001
|
||||
From: Antonio Larrosa <antonio.larrosa@gmail.com>
|
||||
Date: Wed, 5 May 2021 13:45:02 +0200
|
||||
Subject: [PATCH 1/2] Support SQLAlchemy 1.4.x
|
||||
|
||||
SQLAlchemy 1.4 is returning new types, LegacyCursorResult and LegacyRow,
|
||||
which are not JSON serializable and this makes tests fail with:
|
||||
|
||||
```
|
||||
======================================================================
|
||||
ERROR: test_result_proxy (pecan.tests.test_jsonify.TestJsonifySQLAlchemyGenericEncoder)
|
||||
----------------------------------------------------------------------
|
||||
Traceback (most recent call last):
|
||||
File "/home/abuild/rpmbuild/BUILD/pecan-1.3.3/pecan/tests/test_jsonify.py", line 220, in test_result_proxy
|
||||
result = encode(self.result_proxy)
|
||||
File "/home/abuild/rpmbuild/BUILD/pecan-1.3.3/pecan/jsonify.py", line 133, in encode
|
||||
return _instance.encode(obj)
|
||||
File "/usr/lib64/python3.6/json/encoder.py", line 199, in encode
|
||||
chunks = self.iterencode(o, _one_shot=True)
|
||||
File "/usr/lib64/python3.6/json/encoder.py", line 257, in iterencode
|
||||
return _iterencode(o, 0)
|
||||
File "/home/abuild/rpmbuild/BUILD/pecan-1.3.3/pecan/jsonify.py", line 127, in default
|
||||
return jsonify(obj)
|
||||
File "/usr/lib64/python3.6/functools.py", line 807, in wrapper
|
||||
return dispatch(args[0].__class__)(*args, **kw)
|
||||
File "/home/abuild/rpmbuild/BUILD/pecan-1.3.3/pecan/jsonify.py", line 122, in jsonify
|
||||
return _default.default(obj)
|
||||
File "/home/abuild/rpmbuild/BUILD/pecan-1.3.3/pecan/jsonify.py", line 108, in default
|
||||
return JSONEncoder.default(self, obj)
|
||||
File "/usr/lib64/python3.6/json/encoder.py", line 180, in default
|
||||
o.__class__.__name__)
|
||||
TypeError: Object of type 'LegacyCursorResult' is not JSON serializable
|
||||
|
||||
======================================================================
|
||||
ERROR: test_row_proxy (pecan.tests.test_jsonify.TestJsonifySQLAlchemyGenericEncoder)
|
||||
----------------------------------------------------------------------
|
||||
Traceback (most recent call last):
|
||||
File "/home/abuild/rpmbuild/BUILD/pecan-1.3.3/pecan/tests/test_jsonify.py", line 227, in test_row_proxy
|
||||
result = encode(self.row_proxy)
|
||||
File "/home/abuild/rpmbuild/BUILD/pecan-1.3.3/pecan/jsonify.py", line 133, in encode
|
||||
return _instance.encode(obj)
|
||||
File "/usr/lib64/python3.6/json/encoder.py", line 199, in encode
|
||||
chunks = self.iterencode(o, _one_shot=True)
|
||||
File "/usr/lib64/python3.6/json/encoder.py", line 257, in iterencode
|
||||
return _iterencode(o, 0)
|
||||
File "/home/abuild/rpmbuild/BUILD/pecan-1.3.3/pecan/jsonify.py", line 127, in default
|
||||
return jsonify(obj)
|
||||
File "/usr/lib64/python3.6/functools.py", line 807, in wrapper
|
||||
return dispatch(args[0].__class__)(*args, **kw)
|
||||
File "/home/abuild/rpmbuild/BUILD/pecan-1.3.3/pecan/jsonify.py", line 122, in jsonify
|
||||
return _default.default(obj)
|
||||
File "/home/abuild/rpmbuild/BUILD/pecan-1.3.3/pecan/jsonify.py", line 108, in default
|
||||
return JSONEncoder.default(self, obj)
|
||||
File "/usr/lib64/python3.6/json/encoder.py", line 180, in default
|
||||
o.__class__.__name__)
|
||||
TypeError: Object of type 'LegacyRow' is not JSON serializable
|
||||
```
|
||||
|
||||
The SQLALchemy migration guide at [1] says:
|
||||
```
|
||||
For mapping-like behaviors from a Row object, including support for
|
||||
these methods as well as a key-oriented __contains__ operator, the API
|
||||
going forward will be to first access a special attribute Row._mapping,
|
||||
which will then provide a complete mapping interface to the row, rather
|
||||
than a tuple interface.
|
||||
```
|
||||
|
||||
This commit fixes this by handling these new returned classes as a
|
||||
special case and using _mapping to convert them to dicts.
|
||||
|
||||
[1] https://docs.sqlalchemy.org/en/14/changelog/migration_14.html#rowproxy-is-no-longer-a-proxy-is-now-called-row-and-behaves-like-an-enhanced-named-tuple
|
||||
---
|
||||
pecan/jsonify.py | 18 ++++++++++++++++++
|
||||
1 file changed, 18 insertions(+)
|
||||
|
||||
diff --git a/pecan/jsonify.py b/pecan/jsonify.py
|
||||
index 5b74877..5da9638 100644
|
||||
--- a/pecan/jsonify.py
|
||||
+++ b/pecan/jsonify.py
|
||||
@@ -33,6 +33,19 @@ except ImportError: # pragma no cover
|
||||
pass
|
||||
|
||||
|
||||
+try:
|
||||
+ from sqlalchemy.engine.cursor import LegacyCursorResult, LegacyRow
|
||||
+except ImportError: # pragma no cover
|
||||
+ # dummy classes since we don't have SQLAlchemy installed
|
||||
+ # or we're using SQLAlchemy < 1.4
|
||||
+
|
||||
+ class ResultProxy(object): # noqa
|
||||
+ pass
|
||||
+
|
||||
+ class RowProxy(object): # noqa
|
||||
+ pass
|
||||
+
|
||||
+
|
||||
#
|
||||
# encoders
|
||||
#
|
||||
@@ -100,6 +113,11 @@ class GenericJSON(JSONEncoder):
|
||||
if props['count'] < 0:
|
||||
props['count'] = len(props['rows'])
|
||||
return props
|
||||
+ elif isinstance(obj, LegacyCursorResult):
|
||||
+ rows = [dict(row._mapping) for row in obj.fetchall()]
|
||||
+ return {'count': len(rows), 'rows': rows}
|
||||
+ elif isinstance(obj, LegacyRow):
|
||||
+ return dict(obj._mapping)
|
||||
elif isinstance(obj, RowProxy):
|
||||
return dict(obj)
|
||||
elif isinstance(obj, webob_dicts):
|
||||
--
|
||||
2.31.1
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
From 942d92e7eb83e2eccb5d172b226b8e5fdc2d0368 Mon Sep 17 00:00:00 2001
|
||||
From: Antonio Larrosa <antonio.larrosa@gmail.com>
|
||||
Date: Wed, 5 May 2021 13:57:57 +0200
|
||||
Subject: [PATCH 2/2] Fix typo from bad copy&paste
|
||||
|
||||
I copied the structure of the code from a few lines above and forgot
|
||||
to change the name of the classes
|
||||
---
|
||||
pecan/jsonify.py | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/pecan/jsonify.py b/pecan/jsonify.py
|
||||
index 5da9638..c5cbc15 100644
|
||||
--- a/pecan/jsonify.py
|
||||
+++ b/pecan/jsonify.py
|
||||
@@ -39,10 +39,10 @@ except ImportError: # pragma no cover
|
||||
# dummy classes since we don't have SQLAlchemy installed
|
||||
# or we're using SQLAlchemy < 1.4
|
||||
|
||||
- class ResultProxy(object): # noqa
|
||||
+ class LegacyCursorResult(object): # noqa
|
||||
pass
|
||||
|
||||
- class RowProxy(object): # noqa
|
||||
+ class LegacyRow(object): # noqa
|
||||
pass
|
||||
|
||||
|
||||
--
|
||||
2.31.1
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4b2acd6802a04b59e306d0a6ccf37701d24376f4dc044bbbafba3afdf9d3389a
|
||||
size 124233
|
||||
3
pecan-1.4.1.tar.gz
Normal file
3
pecan-1.4.1.tar.gz
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2cbd0eedbb5747c04cdf18c4aae4f1c6e9d950f3af70af2544b074f7ed7a0480
|
||||
size 124777
|
||||
@@ -1,3 +1,15 @@
|
||||
-------------------------------------------------------------------
|
||||
Sat Dec 11 22:31:15 UTC 2021 - Dirk Müller <dmueller@suse.com>
|
||||
|
||||
- update to 1.4.1:
|
||||
* add support for Python 3.10
|
||||
* added trove classifiers for Python 3.6 - 3.9
|
||||
* fixed a bug related to setuptools as a dependency
|
||||
* fixed a bug that broke pecan when used with certain
|
||||
versions of SQLAlchemy
|
||||
- drop 0001-Support-SQLAlchemy-1.4.x.patch,
|
||||
0002-Fix-typo-from-bad-copy-paste.patch: obsolete (upstream)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Oct 5 14:24:02 UTC 2021 - Stefan Schubert <schubi@suse.de>
|
||||
|
||||
|
||||
@@ -25,15 +25,13 @@
|
||||
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
||||
%define skip_python2 1
|
||||
Name: python-pecan
|
||||
Version: 1.4.0
|
||||
Version: 1.4.1
|
||||
Release: 0
|
||||
Summary: A WSGI object-dispatching web framework
|
||||
License: BSD-3-Clause
|
||||
URL: https://github.com/pecan/pecan
|
||||
Source: https://files.pythonhosted.org/packages/source/p/pecan/pecan-%{version}.tar.gz
|
||||
Patch0: pecan-no-kajiki.patch
|
||||
Patch1: 0001-Support-SQLAlchemy-1.4.x.patch
|
||||
Patch2: 0002-Fix-typo-from-bad-copy-paste.patch
|
||||
BuildRequires: %{python_module Genshi >= 0.7}
|
||||
BuildRequires: %{python_module Jinja2}
|
||||
BuildRequires: %{python_module Mako >= 0.4.0}
|
||||
@@ -78,8 +76,6 @@ A WSGI object-dispatching web framework.
|
||||
%prep
|
||||
%setup -q -n pecan-%{version}
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
sed -ie "/^uwsgi$/d" test-requirements.txt
|
||||
sed -ie "/^pep8$/d" test-requirements.txt
|
||||
|
||||
|
||||
Reference in New Issue
Block a user