Skip to content

Commit

Permalink
Merge ad5e43c into 878ff92
Browse files Browse the repository at this point in the history
  • Loading branch information
tisto committed Dec 20, 2020
2 parents 878ff92 + ad5e43c commit 4dc4ae2
Show file tree
Hide file tree
Showing 17 changed files with 172 additions and 59 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,60 @@
name: plone.rest CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.7, 2.7]
plone-version: [5.2, 5.1, 4.3]
exclude:
- python-version: 3.7
plone-version: 4.3
- python-version: 3.7
plone-version: 4.3

steps:

# git checkout
- uses: actions/checkout@v2

# python setup
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

# python cache
- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
# python install
- run: pip install virtualenv
- run: pip install wheel
- name: pip install
run: pip install -r requirements.txt
- name: choose Plone version
run: sed -ie "s#plone-x.x.x.cfg#plone-${{ matrix.plone-version }}.x.cfg#" ci.cfg

# buildout
- name: buildout
run: buildout -t 10 -c ci.cfg
env:
CI: true

# black
- name: black
run: if [ "${{ matrix.plone-version }}" == "5.2" ] && [ ${{ matrix.python-version }} == '3.7' ]; then pip install black && black src/ --check; fi

# code analysis
- name: black
run: bin/code-analysis

# test
- name: test
run: bin/test
10 changes: 8 additions & 2 deletions Makefile
Expand Up @@ -3,7 +3,7 @@
SHELL := /bin/bash
CURRENT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

version = 3.7
version = 3

# We like colors
# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects
Expand All @@ -27,7 +27,7 @@ update: ## Update Make and Buildout
wget -O plone-4.3.x.cfg https://raw.githubusercontent.com/kitconcept/buildout/master/plone-4.3.x.cfg
wget -O plone-5.1.x.cfg https://raw.githubusercontent.com/kitconcept/buildout/master/plone-5.1.x.cfg
wget -O plone-5.2.x.cfg https://raw.githubusercontent.com/kitconcept/buildout/master/plone-5.2.x.cfg
wget -O travis.cfg https://raw.githubusercontent.com/kitconcept/buildout/master/travis.cfg
wget -O ci.cfg https://raw.githubusercontent.com/kitconcept/buildout/master/travis.cfg
wget -O versions.cfg https://raw.githubusercontent.com/kitconcept/buildout/master/versions.cfg

.installed.cfg: bin/buildout *.cfg
Expand Down Expand Up @@ -71,6 +71,12 @@ build-plone-5.2: .installed.cfg ## Build Plone 5.2
bin/pip install -r requirements.txt
bin/buildout -c plone-5.2.x.cfg

.PHONY: Build Plone 5.2 Performance
build-plone-5.2-performance: .installed.cfg ## Build Plone 5.2
bin/pip install --upgrade pip
bin/pip install -r requirements.txt
bin/buildout -c plone-5.2.x-performance.cfg

.PHONY: Test
test: ## Test
bin/test
Expand Down
1 change: 0 additions & 1 deletion base.cfg
Expand Up @@ -58,7 +58,6 @@ eggs =
towncrier
readme
docutils
httpie

[sources]
plone.dexterity = git git://github.com/plone/plone.dexterity.git pushurl=git@github.com:plone/plone.dexterity.git branch=plip-680
Expand Down
7 changes: 7 additions & 0 deletions ci.cfg
@@ -0,0 +1,7 @@
[buildout]
extends = plone-x.x.x.cfg

[code-analysis]
recipe = plone.recipe.codeanalysis
pre-commit-hook = False
return-status-codes = True
38 changes: 15 additions & 23 deletions plone-4.3.x.cfg
@@ -1,38 +1,30 @@
[buildout]
extends =
base.cfg
http://dist.plone.org/release/4.3.19/versions.cfg
https://dist.plone.org/release/4.3.20/versions.cfg
versions.cfg

[versions]
plone.testing = 5.0.0
pytz = 2017.3
zope.interface = 4.1.0

# fixes zlib failure: https://stackoverflow.com/questions/34631806/fail-during-installation-of-pillow-python-module-in-linux
# Pillow = 5.4.1
future = 0.17.1
six = 1.11.0

# Required for Python 2.7 compatibility
more-itertools = <6.0.0
zipp = >=0.5, <2a

# plone.restapi specific
plone.schema = 1.2.0
# fixes: SyntaxError: invalid syntax (more.py, line 340)
zipp = 0.5.2

# zest.releaser
zest.releaser = 6.20.1
twine = 1.11.0
requests = 2.22.0
towncrier = 19.2.0
zestreleaser.towncrier = 1.1.0
# docutils = 0.13.1
# more-itertools >= 6.0.0 dropped python2.7 support
more-itertools = 5.0.0

# Sphinx
Sphinx = 1.6.5
docutils = 0.14
# Error: The requirement ('Pygments>=2.5.1') is not allowed by your [versions] constraint (2.2.0)
Pygments = 2.5.2
sphinxcontrib-httpexample = 0.7.0
sphinxcontrib-httpdomain = 1.5.0
sphinx-rtd-theme = 0.2.4
Jinja2 = 2.10
Babel = 2.5.1
astunparse = 1.6.2

# Last pyrsistent version that is python 2 compatible:
pyrsistent = 0.15.7

# Error: The requirement ('distlib<1,>=0.3.1') is not allowed by your [versions] constraint (0.3.0)
distlib = 0.3.1
19 changes: 12 additions & 7 deletions plone-5.1.x.cfg
@@ -1,30 +1,35 @@
[buildout]
extends =
base.cfg
http://dist.plone.org/release/5.1.6/versions.cfg
https://dist.plone.org/release/5.1.7/versions.cfg
versions.cfg

[versions]
plone.testing = 5.0.0

# Error: The requirement ('virtualenv>=20.0.35') is not allowed by your [versions] constraint (20.0.26)
virtualenv = 20.0.35

# Error: The requirement ('distlib<1,>=0.3.1') is not allowed by your [versions] constraint (0.3.0)
distlib = 0.3.1

# fixes: SyntaxError: invalid syntax (more.py, line 340)
zipp = 0.5.2

# plone.restapi specific
plone.schema = 1.2.0

# zest.releaser
zest.releaser = 6.20.1
twine = 1.11.0
requests = 2.22.0
towncrier = 19.2.0
zestreleaser.towncrier = 1.1.0
# docutils = 0.13.1

# Sphinx
Sphinx = 1.6.5
docutils = 0.14
Pygments = 2.5.2
Pygments = 2.5.1
sphinxcontrib-httpexample = 0.7.0
sphinxcontrib-httpdomain = 1.5.0
sphinx-rtd-theme = 0.2.4
Jinja2 = 2.10
Babel = 2.5.1
astunparse = 1.6.2
astunparse = 1.6.2
16 changes: 12 additions & 4 deletions plone-5.2.x.cfg
@@ -1,10 +1,18 @@
[buildout]
extends =
base.cfg
http://dist.plone.org/release/5.2.1/versions.cfg
find-links += http://dist.plone.org/thirdparty/
https://dist.plone.org/release/5.2.3/versions.cfg
find-links += https://dist.plone.org/thirdparty/
versions=versions

[versions]
# httpie depdendency, Pygments conflicts with
Pygments = 2.5.2
black = 20.8b1

# Error: The requirement ('virtualenv>=20.0.35') is not allowed by your [versions] constraint (20.0.26)
virtualenv = 20.0.35

# Error: The requirement ('pep517>=0.9') is not allowed by your [versions] constraint (0.8.2)
pep517 = 0.9.1

# Error: The requirement ('importlib-metadata>=1') is not allowed by your [versions] constraint (0.23)
importlib-metadata = 2.0.0
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,3 +1,3 @@
# Keep this file in sync with: https://github.com/kitconcept/buildout/edit/master/requirements.txt
setuptools==42.0.2
zc.buildout==2.13.2
zc.buildout==2.13.3
8 changes: 4 additions & 4 deletions src/plone/rest/cors.py
Expand Up @@ -26,8 +26,8 @@ def __init__(self, context, request):

def process_simple_request(self):
"""Process the current request as a simple CORS request by setting the
appropriate access control headers. Returns True if access control
headers were set.
appropriate access control headers. Returns True if access control
headers were set.
"""
origin = self._allowed_origin()
if not origin:
Expand All @@ -43,8 +43,8 @@ def process_simple_request(self):

def process_preflight_request(self):
"""Process the current request as a CORS preflight request by setting
the appropriate access control headers. Returns True if access
control headers were set.
the appropriate access control headers. Returns True if access
control headers were set.
"""
origin = self._allowed_origin()
if not origin:
Expand Down
3 changes: 1 addition & 2 deletions src/plone/rest/errors.py
Expand Up @@ -231,8 +231,7 @@ def attempt_redirect(self):

@memoize
def _url(self):
"""Get the current, canonical URL
"""
"""Get the current, canonical URL"""
return self.request.get(
"ACTUAL_URL",
self.request.get(
Expand Down
2 changes: 1 addition & 1 deletion src/plone/rest/events.py
Expand Up @@ -7,7 +7,7 @@

def mark_as_api_request(event):
"""Mark a request as IAPIRequest if there's a service registered for the
actual request method and Accept header.
actual request method and Accept header.
"""
request = event.request
method = request.get("REQUEST_METHOD", "GET")
Expand Down
8 changes: 3 additions & 5 deletions src/plone/rest/interfaces.py
Expand Up @@ -3,18 +3,16 @@


class IAPIRequest(Interface):
"""Marker for API requests.
"""
"""Marker for API requests."""


class IService(Interface):
"""Marker for REST services.
"""
"""Marker for REST services."""


class ICORSPolicy(Interface):
"""Provides methods for processing simple and preflight CORS requests by
adding access control headers.
adding access control headers.
"""

def process_simple_request():
Expand Down
8 changes: 4 additions & 4 deletions src/plone/rest/negotiation.py
Expand Up @@ -7,7 +7,7 @@

def parse_accept_header(accept):
"""Parse the given Accept header ignoring any parameters and return a list
of media type tuples.
of media type tuples.
"""
media_types = []
for media_range in accept.split(","):
Expand All @@ -20,8 +20,8 @@ def parse_accept_header(accept):

def lookup_service_id(method, accept):
"""Lookup the service id for the given request method and Accept header.
Only Accept headers containing exactly one media type are considered for
negotiation.
Only Accept headers containing exactly one media type are considered for
negotiation.
"""
media_types = parse_accept_header(accept)
if len(media_types) != 1:
Expand All @@ -40,7 +40,7 @@ def lookup_service_id(method, accept):

def register_service(method, media_type):
"""Register a service for the given request method and media type and
return it's service id.
return it's service id.
"""
service_id = u"{}_{}_{}_".format(method, media_type[0], media_type[1])
types = _services.setdefault(method, {})
Expand Down
2 changes: 1 addition & 1 deletion src/plone/rest/patches.py
Expand Up @@ -4,7 +4,7 @@

def __before_publishing_traverse__(self, arg1, arg2=None):
"""Pre-traversal hook that stops traversal to prevent the default view
to be appended. Appending the default view would break REST calls.
to be appended. Appending the default view would break REST calls.
"""
# XXX hack around a bug(?) in BeforeTraverse.MultiHook
REQUEST = arg2 or arg1
Expand Down
3 changes: 1 addition & 2 deletions src/plone/rest/traverse.py
Expand Up @@ -52,8 +52,7 @@ def browserDefault(self, request):

@implementer(IBrowserPublisher)
class RESTWrapper(object):
"""A wrapper for objects traversed during a REST request.
"""
"""A wrapper for objects traversed during a REST request."""

def __init__(self, context, request):
self.context = context
Expand Down
3 changes: 1 addition & 2 deletions src/plone/rest/zcml.py
Expand Up @@ -20,8 +20,7 @@


class IService(Interface):
"""
"""
""""""

method = TextLine(
title=u"The name of the view that should be the default. "
Expand Down

0 comments on commit 4dc4ae2

Please sign in to comment.