ltiapi.utils
#
Module Contents#
Classes#
A class for optional chaining in Python. |
Functions#
Optional |
|
Gives the absolute URI of a resource after reversing. |
|
Generates an RSA key pair. Async because generating a key can be resource intensive. |
|
Method code from https://github.com/dmitry-viskov/pylti1.3-django-example.git |
|
Data#
API#
- ltiapi.utils.ChainedObj#
None
- class ltiapi.utils.Chain(obj: ltiapi.utils.ChainedObj)#
Bases:
typing.Generic
[ltiapi.utils.ChainedObj
]A class for optional chaining in Python.
Contains a tree of
dict
s,list
s andobject
s, that can be queried via__getitem__
([...]
). The object contained in the class can be retrieved via calling theChain
instance. If any of the items or attributes in the getter chain containsNone
, the call return value will beNone
, too.Initialization
- get(key: Any, default=None)#
- __getitem__#
None
- __call__() ltiapi.utils.ChainedObj #
- ltiapi.utils.chain(obj: Any, members: Sequence[Any], default=None)#
Optional
Chain
as a function. The most capable getter you have ever seen.:param obj: the object to wrap.
:param args:
Sequence
of object members that will be used to get into the object’s members.:returns: the sought member or the default value.
- ltiapi.utils.build_absolute_uri_without_request(url: str, query: str = '', host: str = settings.LINK_BASE, protocol: Optional[str] = 'https')#
Gives the absolute URI of a resource after reversing.
request.build_absolute_uri()
should be used for this usually, but sometimes therequest
is not available.:param url: a site-relative url
:param query: the url query string. Defaults to an empty string.
:param host: the current host. defaults to
settings.LINK_BASE
.:param protocol: you can specify a protocol (
http(s)
) here. Defaults tohttps
.
- async ltiapi.utils.generate_key_pair(key_size=4096)#
Generates an RSA key pair. Async because generating a key can be resource intensive.
:param key_size: key bits
:returns: a dict with the keys “public” and “private”, containing PEM-encoded RSA keys. This is not returned as a tuple so that the user of this function never confuses them.
- async ltiapi.utils.keys_for_issuer(issuer_name: str) pylti1p3.contrib.django.lti1p3_tool_config.models.LtiToolKey #
- async ltiapi.utils.make_tool_config_from_openid_config_via_link(openid_config: Dict[str, Any], openid_registration: Dict[str, Any], one_off_registration: ltiapi.models.OneOffRegistrationLink)#
- ltiapi.utils.lti_registration_data(request: django.http.HttpRequest)#
- ltiapi.utils.get_launch_url(request: django.http.HttpRequest)#
Method code from https://github.com/dmitry-viskov/pylti1.3-django-example.git
- ltiapi.utils.user_transform#
None
- ltiapi.utils.ROLE_START#
‘http://purl.imsglobal.org/vocab/lis/v2/’
- ltiapi.utils.get_roles(message_launch_data: dict) List[django.contrib.auth.models.Group] #
- ltiapi.utils.is_superior(user: ltiapi.models.LTIUser) bool #
- ltiapi.utils.CLAIM#
‘https://purl.imsglobal.org/spec/lti/claim’
- ltiapi.utils.get_message_data(message_launch_data: dict, data: str)#
- ltiapi.utils.get_lti_tool(tool_conf: pylti1p3.contrib.django.lti1p3_tool_config.DjangoDbToolConf, message_launch_data: dict) dict #
- ltiapi.utils.get_lms(message_launch_data: dict)#
- ltiapi.utils.get_course_from_launch_data(message_launch_data: dict) ltiapi.models.Course #
- ltiapi.utils.get_user_from_launch_data(message_launch_data: dict, lti_tool: pylti1p3.contrib.django.lti1p3_tool_config.models.LtiTool) ltiapi.models.LTIUser #