Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for Python 2.7, 3.5, 3.6 #15

Merged
merged 5 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,28 @@ jobs:
fail-fast: false
matrix:
os:
- ubuntu
- ["ubuntu", "ubuntu-20.04"]
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"]
- ["3.10", "py310"]
- ["3.11", "py311"]
- ["3.9", "coverage"]

runs-on: ${{ matrix.os }}-latest
runs-on: ${{ matrix.os[1] }}
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
name: ${{ matrix.config[1] }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.config[0] }}
- name: Pip cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.config[0] }}-${{ hashFiles('setup.*', 'tox.ini') }}
Expand All @@ -55,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 }}
5 changes: 2 additions & 3 deletions .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# https://github.com/zopefoundation/meta/tree/master/config/zope-product
[meta]
template = "zope-product"
commit-id = "9a5db8c650c45a439db06e3a7b2b86318006659d"
commit-id = "e5c611fb"

[python]
with-pypy = false
with-legacy-python = true
with-sphinx-doctests = false
with-windows = false
with-future-python = false
with-macos = false

[tox]
use-flake8 = true
Expand All @@ -22,7 +22,6 @@ known_zope = "AccessControl, Products.Five, Testing, ZPublisher"

[manifest]
additional-rules = [
"include buildout4.cfg",
"recursive-include src *.po",
"recursive-include src *.pot",
"recursive-include src *.pt",
Expand Down
6 changes: 4 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
Changelog
=========

2.3 (unreleased)
3.0 (unreleased)
----------------

* Drop support for Python 2.7, 3.5, 3.6.

* Lint the code.

* Add support for Python 3.10.
* Add support for Python 3.10 and 3.11.


2.2 (2020-10-26)
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ include buildout.cfg
include tox.ini

recursive-include src *.py
include buildout4.cfg
recursive-include src *.po
recursive-include src *.pot
recursive-include src *.pt
Expand Down
4 changes: 0 additions & 4 deletions buildout4.cfg

This file was deleted.

4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -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 All @@ -19,7 +19,7 @@ ignore-bad-ideas =
force_single_line = True
combine_as_imports = True
sections = FUTURE,STDLIB,THIRDPARTY,ZOPE,FIRSTPARTY,LOCALFOLDER
known_third_party = six, docutils, pkg_resources
known_third_party = six, docutils, pkg_resources, pytz
known_zope = AccessControl, Products.Five, Testing, ZPublisher
known_first_party =
default_section = ZOPE
Expand Down
14 changes: 5 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup


version = '2.3.dev0'
version = '3.0.dev0'

setup(
name='five.formlib',
Expand All @@ -10,32 +10,28 @@
license='ZPL 2.1',
description='zope.formlib integration for Zope.',
author='Zope Foundation',
author_email='zope-dev@zope.org',
author_email='zope-dev@zope.dev',
long_description=(open("README.rst").read() + "\n" +
open("CHANGES.rst").read()),
classifiers=[
'Development Status :: 6 - Mature',
"Development Status :: 6 - Mature",
"Environment :: Web Environment",
"Framework :: Zope :: 4",
"Framework :: Zope :: 5",
"Intended Audience :: Developers",
"License :: OSI Approved :: Zope Public License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"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",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
"Topic :: Software Development :: Libraries :: Application Frameworks",
],
keywords='zope zope4 five formlib',
keywords='zope zope5 five formlib',
packages=['five', 'five.formlib'],
package_dir={'': 'src'},
namespace_packages=['five'],
Expand Down
17 changes: 1 addition & 16 deletions src/five/formlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,6 @@
from zope.schema.interfaces import ValidationError


try:
# Zope 4.x
from Products.Five.browser.decode import processInputs
from Products.Five.browser.decode import setPageEncoding
except ImportError:
# Zope 5.x
def processInputs(*args):
pass

def setPageEncoding(*args):
pass


_ = MessageFactory('zope')


Expand All @@ -72,8 +59,6 @@ class EditView(BrowserView):

def __init__(self, context, request):
BrowserView.__init__(self, context, request)
processInputs(self.request, self.charsets)
setPageEncoding(self.request)
self._setUpWidgets()

def _setUpWidgets(self):
Expand Down Expand Up @@ -180,7 +165,7 @@ def create(self, *args, **kw):
# hack to please typical Zope 2 factories, which expect id and title
# Any sane schema will use a unicode title, and may fail on a
# non-unicode one.
args = ('tmp_id', u'Temporary title') + args
args = ('tmp_id', 'Temporary title') + args
return self._factory(*args, **kw)

def createAndAdd(self, data):
Expand Down
4 changes: 2 additions & 2 deletions src/five/formlib/formbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
_SUBPAGEFORM_PATH = os.path.join(_FORMLIB_DIR, 'subpageform.pt')


class FiveFormlibMixin(object):
class FiveFormlibMixin:

# Overrides the formlib.form.FormBase.template attributes implemented
# using NamedTemplates. NamedTemplates using ViewPageTemplateFile (like
Expand All @@ -50,7 +50,7 @@ def update(self):
'Content-Type',
'text/html; charset=%s' % HTTPRequest.default_encoding
)
super(FiveFormlibMixin, self).update()
super().update()


class FormBase(FiveFormlibMixin, form.FormBase):
Expand Down
4 changes: 2 additions & 2 deletions src/five/formlib/metaconfigure.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

def EditViewFactory(name, schema, label, permission, layer,
template, default_template, bases, for_, fields,
fulledit_path=None, fulledit_label=None, menu=u''):
fulledit_path=None, fulledit_label=None, menu=''):
class_ = SimpleViewClass(template, globals(), used_for=schema,
bases=bases)
class_.schema = schema
Expand Down Expand Up @@ -99,7 +99,7 @@ def AddViewFactory(name, schema, label, permission, layer,
template, default_template, bases, for_,
fields, content_factory, arguments,
keyword_arguments, set_before_add, set_after_add,
menu=u''):
menu=''):
class_ = SimpleViewClass(template, globals(), used_for=schema,
bases=bases)

Expand Down
14 changes: 7 additions & 7 deletions src/five/formlib/tests/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@
class IContent(Interface):

id = ASCIILine(
title=_(u"Id"),
description=_(u"The object id."),
title=_("Id"),
description=_("The object id."),
default='',
required=True
)

title = TextLine(
title=_(u"Title"),
description=_(u"A short description of the event."),
default=u"",
title=_("Title"),
description=_("A short description of the event."),
default="",
required=True
)

somelist = List(
title=_(u"Some List"),
value_type=TextLine(title=_(u"Some item")),
title=_("Some List"),
value_type=TextLine(title=_("Some item")),
default=[],
required=False
)
Expand Down
19 changes: 2 additions & 17 deletions src/five/formlib/tests/formlib.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ zope/formlib/form.txt for tests and more explanations of zope.formlib

Before we can begin, we need to set up a few things.

We prepare for Python 2/3 compatibility:

>>> import six

We need a manager account:

>>> uf = self.folder.acl_users
Expand Down Expand Up @@ -53,23 +49,12 @@ Let's 'manually' create a Content instance and add it to the folder:
>>> print(folder.content_1.title)
Title

Now we can edit this content object, e.g. changing the title. Formlib,
like the traditional AddView and EditView, supports unicode.
But we need some hackery for Python 2/3 compatibility. For Python 2,
the test framework expects utf-8 encoded binary strings; for Python 3,
it expects text. The function below converts as necessary.

>>> def to_input(v):
... if six.PY2:
... return v.encode("utf-8")
... else:
... return v

Now we can edit this content object, e.g. changing the title.

>>> browser.open("http://localhost/test_folder_1_/ftf/content_1/@@edit_content")
>>> ni_hao = u'\u4f60\u597d'
>>> ctl = browser.getControl(name="form.title")
>>> ctl.value = to_input(ni_hao)
>>> ctl.value = ni_hao
>>> browser.getControl(name="form.actions.apply").click()
>>> folder.content_1.title == ni_hao
True
Expand Down
Loading