Skip to content

Commit

Permalink
- Drop support for Python 2.7, 3.5, 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
dataflake committed Jan 31, 2023
1 parent 45e71f8 commit 60abc1f
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 55 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/tests.yml
Expand Up @@ -21,9 +21,6 @@ jobs:
config:
# [Python version, tox env]
- ["3.9", "lint"]
- ["2.7", "py27"]
- ["3.5", "py35"]
- ["3.6", "py36"]
- ["3.7", "py37"]
- ["3.8", "py38"]
- ["3.9", "py39"]
Expand Down Expand Up @@ -57,7 +54,7 @@ jobs:
- name: Coverage
if: matrix.config[1] == 'coverage'
run: |
pip install coveralls coverage-python-version
pip install coveralls
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 1 addition & 3 deletions .meta.toml
Expand Up @@ -2,11 +2,10 @@
# https://github.com/zopefoundation/meta/tree/master/config/zope-product
[meta]
template = "zope-product"
commit-id = "d6240444ec6c9e203f2fd9f62c3e6038f9189e96"
commit-id = "e5c611fb"

[python]
with-pypy = false
with-legacy-python = true
with-sphinx-doctests = false
with-windows = false
with-future-python = false
Expand All @@ -25,6 +24,5 @@ known_third_party = "mock, six, sqlalchemy, testfixtures"

[manifest]
additional-rules = [
"include buildout4.cfg",
"recursive-include src *.zpt",
]
1 change: 0 additions & 1 deletion MANIFEST.in
Expand Up @@ -7,5 +7,4 @@ include buildout.cfg
include tox.ini

recursive-include src *.py
include buildout4.cfg
recursive-include src *.zpt
2 changes: 1 addition & 1 deletion setup.cfg
@@ -1,7 +1,7 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/zope-product
[bdist_wheel]
universal = 1
universal = 0

[flake8]
doctests = 1
Expand Down
10 changes: 3 additions & 7 deletions setup.py
Expand Up @@ -28,22 +28,18 @@
author='Andreas Jung',
author_email='info@zopyx.com',
maintainer='Zope Foundation and Contributors',
maintainer_email='zope-dev@zope.org',
maintainer_email='zope-dev@zope.dev',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: Zope Public License',
'Operating System :: OS Independent',
'Framework :: Zope',
'Framework :: Zope :: 4',
'Framework :: Zope :: 5',
'Programming Language :: Python',
'Topic :: Database',
'Topic :: Database :: Front-Ends',
'Topic :: Software Development :: Libraries :: Python Modules',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
Expand All @@ -60,9 +56,9 @@
python_requires='>=3.7',
install_requires=[
'setuptools',
'SQLAlchemy <1.4', # SQLAlchemy 1.4 doesn't support Python 3.5
'SQLAlchemy <2', # z3c.sqlalchemy 1.5.2 incompatible with SQLAlchemy 2
'z3c.sqlalchemy >1.5.1',
'Products.ZSQLMethods'],
extras_require={'test': ['testfixtures', 'mock']},
extras_require={'test': ['testfixtures']},
namespace_packages=['Products'],
)
32 changes: 8 additions & 24 deletions src/Products/SQLAlchemyDA/da.py
Expand Up @@ -11,8 +11,6 @@
import time
import warnings

import six

from AccessControl import ClassSecurityInfo
from AccessControl.class_init import InitializeClass
from AccessControl.Permissions import view_management_screens
Expand All @@ -22,7 +20,6 @@

from z3c.sqlalchemy import createSAWrapper
from z3c.sqlalchemy import getSAWrapper
from z3c.sqlalchemy.interfaces import ISQLAlchemyWrapper
from zope.sqlalchemy import mark_changed


Expand Down Expand Up @@ -174,7 +171,7 @@ def manage_afterAdd(self, item, container):

def _new_utilid(self):
""" Assign a new unique utility ID """
self.util_id = '%s.%s' % (time.time(), random.random())
self.util_id = f'{time.time()}.{random.random()}'

def allQuotingStyles(self):
return ('standard', 'no-quote')
Expand Down Expand Up @@ -475,9 +472,9 @@ def manage_doQuery(self, query):
@security.protected(view_management_screens)
def manage_formatItem(self, s):
""" used by query form """
if isinstance(s, six.text_type):
if isinstance(s, str):
return s
if isinstance(s, six.binary_type):
if isinstance(s, bytes):
return s.decode(self.encoding, 'ignore')
return str(s)

Expand All @@ -486,24 +483,11 @@ def manage_editProperties(self, REQUEST):
""" Intercept changed properties in order to perform
further actions.
"""
try:
# zope 2.10
from zope.component import unregisterUtility
unregisterUtility(name=self.util_id)
self._new_utilid()
except ImportError:
try:
# zope 2.8
from zope.app import zapi
from zope.component.servicenames import Utilities
s = zapi.getGlobalServices().getService(Utilities)
s.register((), ISQLAlchemyWrapper, self.util_id, None)
self._new_utilid()
except Exception:
# Zope 2.9 ATT: fix this
self._new_utilid()

return super(SAWrapper, self).manage_editProperties(REQUEST)
from zope.component import unregisterUtility
unregisterUtility(name=self.util_id)
self._new_utilid()

return super().manage_editProperties(REQUEST)

manage_workspace = PageTemplateFile('pt/info', globals(),
__name__='manage_workspace')
Expand Down
14 changes: 7 additions & 7 deletions src/Products/SQLAlchemyDA/tests/test_SQLAlchemyDA.py
Expand Up @@ -4,8 +4,8 @@

import copy
import os
from unittest.mock import patch

from mock import patch
from sqlalchemy import Column
from sqlalchemy import Integer
from sqlalchemy import MetaData
Expand Down Expand Up @@ -61,8 +61,8 @@ def afterSetUp(self):
metadata.bind = wrapper.engine
metadata.create_all()
session = wrapper.session
t1 = Test(id=1, utext=u'Hello world', text='hello world')
t2 = Test(id=2, utext=u'foo', text='far')
t1 = Test(id=1, utext='Hello world', text='hello world')
t2 = Test(id=2, utext='foo', text='far')
session.add(t1)
session.add(t2)

Expand Down Expand Up @@ -186,17 +186,17 @@ def testZsqlInsertWithRollback(self):
self.assertEqual(len(rows), 0)

def testORMInsertWithCommit(self):
t1 = Test(id=8, utext=u'Hello world', text='hello world')
t2 = Test(id=9, utext=u'foo', text='far')
t1 = Test(id=8, utext='Hello world', text='hello world')
t2 = Test(id=9, utext='foo', text='far')
self.session.add(t1)
self.session.add(t2)
self.publish(self.folder_path)
rows = self.session.query(Test).all()
self.assertEqual(len(rows), 2)

def testORMInsertWithRollback(self):
t1 = Test(id=8, utext=u'Hello world', text='hello world')
t2 = Test(id=9, utext=u'foo', text='far')
t1 = Test(id=8, utext='Hello world', text='hello world')
t2 = Test(id=9, utext='foo', text='far')
self.session.add(t1)
self.session.add(t2)
transaction.abort()
Expand Down
9 changes: 1 addition & 8 deletions tox.ini
Expand Up @@ -4,9 +4,6 @@
minversion = 3.18
envlist =
lint
py27
py35
py36
py37
py38
py39
Expand All @@ -20,8 +17,7 @@ deps =
zc.buildout >= 3.0.1
wheel > 0.37
commands_pre =
py27,py35: {envbindir}/buildout -nc {toxinidir}/buildout4.cfg buildout:directory={envdir} buildout:develop={toxinidir} install test
!py27-!py35: {envbindir}/buildout -nc {toxinidir}/buildout.cfg buildout:directory={envdir} buildout:develop={toxinidir} install test
{envbindir}/buildout -nc {toxinidir}/buildout.cfg buildout:directory={envdir} buildout:develop={toxinidir} install test
commands =
{envdir}/bin/test {posargs:-cv}

Expand All @@ -33,7 +29,6 @@ allowlist_externals =
mkdir
commands =
isort --check-only --diff {toxinidir}/src {toxinidir}/setup.py
- flake8 {toxinidir}/src {toxinidir}/setup.py
flake8 {toxinidir}/src {toxinidir}/setup.py
check-manifest
check-python-versions
Expand Down Expand Up @@ -63,7 +58,6 @@ allowlist_externals =
deps =
{[testenv]deps}
coverage
coverage-python-version
commands =
mkdir -p {toxinidir}/parts/htmlcov
coverage run {envdir}/bin/test {posargs:-cv}
Expand All @@ -72,7 +66,6 @@ commands =

[coverage:run]
branch = True
plugins = coverage_python_version
source = Products.SQLAlchemyDA

[coverage:report]
Expand Down

0 comments on commit 60abc1f

Please sign in to comment.