Skip to content
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
22 changes: 12 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
LTI 1.3 Advantage Tool implementation in Python
===============================================

.. image:: https://img.shields.io/pypi/v/PyLTI1p3
This is a fork of the `pylti1p3 <https://github.com/dmitry-viskov/pylti1.3>`_ package, originally written by Dmitry Viskov.

.. image:: https://img.shields.io/pypi/v/pylti1p3next
:scale: 100%
:target: https://pypi.python.org/pypi/PyLTI1p3
:target: https://pypi.python.org/pypi/pylti1p3next
:alt: PyPI

.. image:: https://img.shields.io/pypi/pyversions/PyLTI1p3
.. image:: https://img.shields.io/pypi/pyversions/pylti1p3next
:scale: 100%
:target: https://www.python.org/
:alt: Python

.. image:: https://github.com/dmitry-viskov/pylti1.3/actions/workflows/tox.yml/badge.svg
.. image:: https://github.com/pymsglobal/pylti1p3next/actions/workflows/tox.yml/badge.svg
:scale: 100%
:target: https://github.com/dmitry-viskov/pylti1.3/actions
:target: https://github.com/pymsglobal/pylti1p3next/actions
:alt: Build Status

.. image:: https://img.shields.io/github/license/dmitry-viskov/pylti1.3
.. image:: https://img.shields.io/github/license/pymsglobal/pylti1p3next
:scale: 100%
:target: https://raw.githubusercontent.com/dmitry-viskov/pylti1.3/master/LICENSE
:target: https://raw.githubusercontent.com/pymsglobal/pylti1p3next/master/LICENSE
:alt: MIT


Expand All @@ -30,9 +32,9 @@ This library contains adapters for use with the Django and Flask web frameworks.
Usage Examples
=================

Django: https://github.com/dmitry-viskov/pylti1.3-django-example
Django: https://github.com/pymsglobal/pylti1p3next-django-example

Flask: https://github.com/dmitry-viskov/pylti1.3-flask-example
Flask: https://github.com/pymsglobal/pylti1p3next-flask-example

Configuration
=============
Expand Down Expand Up @@ -581,7 +583,7 @@ After this, the special JS code will try to write and then read test cookie inst
`special page`_ that will ask them to open the current URL in the new window if cookies are unavailable. If
cookies are allowed, the user will be transparently redirected to the next page. All texts are configurable with passing arguments:

.. _special page: https://raw.githubusercontent.com/dmitry-viskov/repos-assets/master/pylti1p3/examples/cookies-check/001.png
.. _special page: https://raw.githubusercontent.com/pymsglobal/repos-assets/master/pylti1p3/examples/cookies-check/001.png

.. code-block:: python

Expand Down
11 changes: 6 additions & 5 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ fail-under=10
#from-stdin=

# Files or directories to be skipped. They should be base names, not paths.
ignore=CVS
ignore=

# Add files or directories matching the regular expressions patterns to the
# ignore-list. The regex matches against paths and can be in Posix or Windows
# format. Because '\' represents the directory delimiter on Windows systems, it
# can't be used as an escape character.
ignore-paths=
ignore-paths=^.*/migrations/.*$

# Files or directories matching the regular expression patterns are skipped.
# The regex matches against base names, not paths. The default value ignores
Expand Down Expand Up @@ -77,7 +77,7 @@ limit-inference-results=100

# List of plugins (as comma separated values of python module names) to load,
# usually to register additional checkers.
load-plugins=
load-plugins=pylint_django

# Pickle collected data for later comparisons.
persistent=yes
Expand Down Expand Up @@ -307,8 +307,8 @@ min-public-methods=2
[EXCEPTIONS]

# Exceptions that will emit a warning when caught.
overgeneral-exceptions=BaseException,
Exception
overgeneral-exceptions=builtins.BaseException,
builtins.Exception


[FORMAT]
Expand Down Expand Up @@ -428,6 +428,7 @@ disable=bad-inline-option,
use-symbolic-message-instead,
useless-option-value,
useless-suppression,
django-not-configured,


# Enable the message, report, category or checker with the given id(s). You can
Expand Down
72 changes: 72 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[project]
name = "pylti1p3next"
dynamic = ["version"]
authors = [
{ name="Christian Lawson-Perfect", email="[email protected]"},
{ name="Dmitry Viskov", email="[email protected]"}
]
maintainers = [
{ name="Sébastien Philippot", email="[email protected]" },
{ name="Christian Lawson-Perfect", email="[email protected]"}
]
description = "LTI 1.3 Advantage Tool implementation in Python"
readme = "README.rst"
license = "MIT"
license-files = ["LICENSE"]
requires-python = ">=3.8"
keywords = [
"pylti",
"pylti1p3",
"lti",
"lti1.3",
"lti1p3",
"django",
"flask"
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django",
"Framework :: Flask",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"Intended Audience :: Education",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI",
"Topic :: Security",
"Topic :: Software Development :: Libraries :: Application Frameworks",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"jwcrypto~=1.5",
"pyjwt~=1.5",
"requests~=2.32",
"typing_extensions~=4.2",
]

[project.urls]
Homepage = "https://github.com/pymsglobal/pylti1p3next#readme"
Issues = "https://github.com/pymsglobal/pylti1p3next/issues"
Source = "https://github.com/pymsglobal/pylti1p3next"

[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[tool.setuptools.dynamic]
version = {attr = "pylti1p3.__version__"}

[tool.coverage.paths]
pylti1p3next = ["pylti1p3"]
tests = ["tests"]
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license_file = LICENSE

[flake8]
max_line_length=120
exclude=.git,.idea,.tox,build,venv,venv3,env
exclude=.git,.idea,.tox,build,venv,venv3,env,migrations
extend-ignore=E203

[coverage:run]
Expand Down
72 changes: 0 additions & 72 deletions setup.py

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,17 @@ def find_or_create_lineitem(
if not self.can_create_lineitem():
raise LtiException("Can't create lineitem: Missing required scope")

created_lineitem = self._service_connector.make_service_request(
self._service_data["scope"],
self._service_data["lineitems"],
response = self._service_connector.make_service_request(
scopes=self._service_data["scope"],
url=self._service_data["lineitems"],
is_post=True,
data=new_lineitem.get_value(),
content_type="application/vnd.ims.lis.v2.lineitem+json",
accept="application/vnd.ims.lis.v2.lineitem+json",
)
if not isinstance(created_lineitem["body"], dict):
if not isinstance(response["body"], dict):
raise LtiException("Unknown response type received for create line item")
return LineItem(t.cast(TLineItem, created_lineitem["body"]))
return LineItem(t.cast(TLineItem, response["body"]))

def get_grades(self, lineitem: t.Optional[LineItem] = None) -> list:
"""
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json

from pylti1p3.deployment import Deployment
from pylti1p3.exception import LtiException
from pylti1p3.registration import Registration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ def to_dict(self):
"auth_audience": self.auth_audience,
"key_set_url": self.key_set_url,
"key_set": json.loads(self.key_set) if self.key_set else None,
"deployment_ids": json.loads(self.deployment_ids)
if self.deployment_ids
else [],
"deployment_ids": (
json.loads(self.deployment_ids) if self.deployment_ids else []
),
}
return data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def __init__(
self,
request,
tool_config,
*,
session_service=None,
cookie_service=None,
launch_data_storage=None,
Expand All @@ -27,12 +28,12 @@ def __init__(
session_service if session_service else DjangoSessionService(request)
)
super().__init__(
django_request,
tool_config,
session_service,
cookie_service,
launch_data_storage,
requests_session,
request=django_request,
tool_config=tool_config,
session_service=session_service,
cookie_service=cookie_service,
launch_data_storage=launch_data_storage,
requests_session=requests_session,
)

def _get_request_param(self, key):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def __init__(
self,
request,
tool_config,
*,
session_service=None,
cookie_service=None,
launch_data_storage=None,
Expand All @@ -27,11 +28,11 @@ def __init__(
session_service if session_service else DjangoSessionService(request)
)
super().__init__(
django_request,
tool_config,
session_service,
cookie_service,
launch_data_storage,
request=django_request,
tool_config=tool_config,
session_service=session_service,
cookie_service=cookie_service,
launch_data_storage=launch_data_storage,
)

def get_redirect(self, url):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,28 @@


class DjangoRequest(Request):
_request = None
request = None
_post_only = False
_default_params = None

@property
def session(self):
return self._request.session
return self.request.session

def __init__(self, request, post_only=False, default_params=None):
self.set_request(request)
self.request = request
self._post_only = post_only
self._default_params = default_params if default_params else {}

def set_request(self, request):
self._request = request

def get_param(self, key):
if self._post_only:
return self._request.POST.get(key, self._default_params.get(key))
return self._request.GET.get(
key, self._request.POST.get(key, self._default_params.get(key))
return self.request.POST.get(key, self._default_params.get(key))
return self.request.GET.get(
key, self.request.POST.get(key, self._default_params.get(key))
)

def get_cookie(self, key):
return self._request.COOKIES.get(key)
return self.request.COOKIES.get(key)

def is_secure(self):
return self._request.is_secure()
return self.request.is_secure()
Loading