Django Tsugi
This is the emerging Tsugi library for Django - https://www.tsugi.org
https://pypi.org/project/django-tsugi/
Quick start
Install
pip install django-tsugi # or pip3
Add “django_tsugi” to your INSTALLED_APPS and add the keyset url for your controlling server in settings.py like this:
INSTALLED_APPS = [ ... 'django_tsugi', ] # To set up Tsugi TSUGI_KEYSET = "https://dev1.tsugicloud.org/tsugi/lti/keyset-ext";Add a line to your application’s urls.py file to handle launches and tell Tsugi which view to redirect to after the launch is successful:
from . import views from django_tsugi.views import LaunchView urlpatterns = [ path('', views.GradeView.as_view(), name='grade' ), path('launch', LaunchView.as_view(), {'success_url' : 'grade'} ), ]Add the TsugiMixin to your class based view and it will define the request.tsugi variable with the user, context, and link information:
from django.views import View from django_tsugi.mixins import TsugiMixin class GradeView(TsugiMixin, View): def get(self, request) : context = {'tsugi': request.tsugi} return render(request, 'grade/main.html', context) def post(self, request) : grade = float(request.POST.get('grade')) comment = request.POST.get('comment') retval = request.tsugi.result.gradeSend(grade, comment) context = {'tsugi': request.tsugi, 'retval' : retval} return render(request, 'grade/done.html', context)
Revising and testing locally
If you are running your Django tool locally and Tsugi locally, you can use the following in settings.py:
TSUGI_KEYSET = "http://localhost:8888/tsugi/lti/keyset-ext";
If you are working on a new version of this library with a django tsugi app, you can release a new version locally with:
python3 setup.py sdist ; pip3 install dist/*.tar.gz
Releasing to pypi.org
This library is released to https://pypi.org/project/django-tsugi/
You need twine to push changes to pypi:
pip3 install twine # If needed pip install --upgrade twine # If needed pip3 install twine==1.12.1 # If needed since later twines mess up
To release a whole new version, update the version in setup.py and then:
rm dist/* ; python3 setup.py sdist ; twine check dist/* twine upload dist/*
You cannot upload the same version number twice.
References
[1] How to write reusable apps - https://docs.djangoproject.com/en/2.2/intro/reusable-apps/
[2] Tutorial on Packaging and Distributing Projects - https://packaging.python.org/tutorials/packaging-projects/
[3] https://pypi.org/ - https://packaging.python.org/tutorials/packaging-projects/#uploading-the-distribution-archives
Metadata
Release files for django-tsugi 0.1.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django-tsugi-0.1.12.tar.gz | 13.7 kB | Without provenance | Details |
Release files / django-tsugi-0.1.12.tar.gz
| Download URL | django-tsugi-0.1.12.tar.gz |
|---|---|
| Size | 13.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea8b3392092553fbb448afcb6203b0448882689d1570a3203da22a4ccc031963
|
|
BLAKE2b-256 checksum How to use checksums |
744d7120871e074404982856df9985271072894180936689953daceca95ae0b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.17.3 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.0
|
Security for django-tsugi 0.1.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.