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

#107 upgrade #108

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[flake8]
application_import_names = pyramid_urireferencer, tests
exclude = .venv,
__pycache__,
import-order-style = pycharm
max-line-length = 90
ignore = E402, E405, W503, F403, F405
42 changes: 42 additions & 0 deletions .github/workflows/urireferencer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Urireferencer backend tests

on:
workflow_dispatch:

pull_request:
paths:
- pyramid_urireferencer/**
- .github/workflows/pyramid_urireferencer.yaml
- scripts/**
- pyproject.toml
- requirements*.txt
- tests/**

push:
branches:
- main
env:
PYTHON_VERSION: '3.11'

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install python requirements
env:
HATCH_BUILD_NO_HOOKS: true
working-directory: ./
run: |
pip --version
pip install pip-tools
pip-sync requirements-dev.txt
pip install -e .

- name: Python tests
run: pytest tests --exitfirst --capture=no -vvv --full-trace
25 changes: 25 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
types: [python]
- id: trailing-whitespace
types: [python]
- repo: https://github.com/psf/black
rev: 24.3.0
hooks:
- id: black
types: [python]
args: [--preview]
exclude: docs, tests
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies:
- flake8-import-order==0.18.2
- flake8-bugbear==24.2.6
types: [python]
exclude: docs
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

54 changes: 54 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
0.7.0 (29-01-2019)
==================

- Better matching on Accept headers (\#18)
- Nieuwe protected decorator toevoegen die de request niet uit de
parent haalt maar rechtstreeks (\#50)

0.6.0 (2017-06-08)
==================

- Add some extra logging. (\#13)
- Add required function [get\_uri]{.title-ref} to the
[AbstractReferencer]{.title-ref} to determine the uri of the current
request (\#7 and \#8)

0.5.0 (2016-09-28)
==================

- Add support for python 3.5
- Some minor doc fixes
- Changed an edge case where [items]{.title-ref} or
[applications]{.title-ref} response attributes could be
[None]{.title-ref} so that they are now always empty lists. (\#6)
- Updated error message and added JSON error message when a backend
application can\'t be reached (\#9) and when a resource can\'t be
deleted (\#10)

0.4.0 (2015-07-10)
==================

- Added module [protected\_resources]{.title-ref} containing a
[protected\_operation]{.title-ref} decorator function.

0.3.0 (2015-06-25)
==================

- Added uri and request to references parameters
- Included renderer in request config
- Removed exception in get\_references view
- Fixed ApplicationResponse title from json

0.2.0 (2015-06-07)
==================

- Changed ApplicationResponse.url to service\_url.
- Cleaned up some documentation.
- Added an AbstractReferencer that has no implementation whatsoever.
- Added Python Wheel support
- Make sure that the uri parameter is properly urlencoded.

0.1.0 (2015-05-21)
==================

- Initial version
49 changes: 0 additions & 49 deletions CHANGES.rst

This file was deleted.

1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pyramid\_urireferencer
======================

This plugin for pyramid helps in handling references to resources in
other applications by allowing querying on references to certain URI\'s.

[![image](https://travis-ci.org/OnroerendErfgoed/pyramid_urireferencer.png?branch=master)](https://travis-ci.org/OnroerendErfgoed/pyramid_urireferencer)

[![image](https://coveralls.io/repos/OnroerendErfgoed/pyramid_urireferencer/badge.png?branch=master)](https://coveralls.io/r/OnroerendErfgoed/pyramid_urireferencer)

[![image](https://badge.fury.io/py/pyramid_urireferencer.png)](http://badge.fury.io/py/pyramid_urireferencer)

Please consult the documentatation for
[UriRegistry](http://uriregistry.readthedocs.org/en/latest/) for more
information on how to use this library.
18 changes: 0 additions & 18 deletions README.rst

This file was deleted.

67 changes: 67 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
version = "1.2.0"
name = "pyramid_urireferencer"
dynamic = ["readme"]
authors = [
{ name = "Flanders Heritage Agency", email = "ict@onroerenderfgoed.be" },
]
description = "A pyramid plugin to handle referencing external URIs."
requires-python = ">=3.10,<3.13"
keywords = ["web", "wsgi", "pyramid", "SKOS", "thesaurus", "vocabulary"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"pyramid==2.0.2",
"requests==2.32.3",
"six==1.16.0"
]

[project.urls]
History = "https://github.com/OnroerendErfgoed/pyramid_urireferencer/blob/master/CHANGES.md"
Tracker = "https://github.com/OnroerendErfgoed/pyramid_urireferencer/issues"
Source = "https://github.com/OnroerendErfgoed/pyramid_urireferencer"
Documentation = "https://pyramid_urireferencer.readthedocs.io/en/latest/"

[project.optional-dependencies]
dev = [
"black==24.4.2",
"coveralls==4.0.1",
"flake8-import-order==0.18.2",
"flake8==7.1.0",
"httpretty==1.1.4",
"mock==5.1.0",
"pre-commit==3.7.1",
"pytest-cov==5.0.0",
"pytest==8.2.2",
"uv==0.2.13",
"webtest==3.0.0"
]

[project.entry-points."paste.app_factory"]
main = "pyramid_urireferencer:main"

##
# Build tool specific
##
[tool.hatch.build.targets.wheel]
# In the wheel we want to have pyramid_urireferencer in the root as python module.
only-include = [
"/pyramid_urireferencer",
]

[tool.hatch.metadata]
# This allows us to use github links as dependencies
allow-direct-references = true

18 changes: 7 additions & 11 deletions pyramid_urireferencer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# -*- coding: utf-8 -*-

from pyramid.path import (
DottedNameResolver
)
from pyramid.path import DottedNameResolver
from zope.interface import Interface

from pyramid_urireferencer import protected_resources
from .referencer import Referencer
from .referencer import Referencer # NoQa
from .renderers import json_renderer


Expand All @@ -16,10 +12,10 @@ class IReferencer(Interface):

def includeme(config):
"""this function adds some configuration for the application"""
config.add_route('references', '/references')
config.add_route("references", "/references")
_add_referencer(config.registry)
config.add_view_deriver(protected_resources.protected_view)
config.add_renderer('json_item', json_renderer)
config.add_renderer("json_item", json_renderer)
config.scan()


Expand All @@ -30,8 +26,8 @@ def _add_referencer(registry):
referencer = registry.queryUtility(IReferencer)
if referencer is not None:
return referencer
ref = registry.settings['urireferencer.referencer']
url = registry.settings['urireferencer.registry_url']
ref = registry.settings["urireferencer.referencer"]
url = registry.settings["urireferencer.registry_url"]
r = DottedNameResolver()
registry.registerUtility(r.resolve(ref)(url), IReferencer)
return registry.queryUtility(IReferencer)
Expand All @@ -44,7 +40,7 @@ def get_referencer(registry):
:rtype: pyramid_urireferencer.referencer.AbstractReferencer
"""
# Argument might be a config or request
regis = getattr(registry, 'registry', None)
regis = getattr(registry, "registry", None)
if regis is None:
regis = registry
return regis.queryUtility(IReferencer)
Loading
Loading