コード例 #1
0
ファイル: application_instances.py プロジェクト: lamcla/lms
def create_application_instance(request):
    """Create application instance in the databse and respond with key and secret."""

    # Default developer_key and developer_secret to None rather than letting
    # them be empty strings.
    developer_key = request.params["developer_key"].strip()
    developer_secret = request.params["developer_secret"].strip()

    # If either one of developer_key or developer_secret is missing, then we
    # don't save the other one either.
    if not developer_key or not developer_secret:
        developer_key = None
        developer_secret = None

    instance = ApplicationInstance.build_from_lms_url(
        request.params["lms_url"],
        request.params["email"],
        developer_key,
        developer_secret,
        request.registry.settings["aes_secret"],
        settings={
            "canvas": {
                "sections_enabled":
                bool(developer_key and request.feature("section_groups"))
            }
        },
    )
    request.db.add(instance)

    return {
        "consumer_key": instance.consumer_key,
        "shared_secret": instance.shared_secret,
    }
コード例 #2
0
 def build_ai_from_pair(pair):
     return ApplicationInstance.build_from_lms_url(
         pair[0], pair[1], None, None, None, None
     )