当前位置: 首页>>代码示例>>Python>>正文


Python backends.get_backend函数代码示例

本文整理汇总了Python中social_auth.backends.get_backend函数的典型用法代码示例。如果您正苦于以下问题:Python get_backend函数的具体用法?Python get_backend怎么用?Python get_backend使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_backend函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: wrapper

        def wrapper(request, backend, *args, **kwargs):
            if redirect_name:
                redirect = reverse(redirect_name, args=(backend,))
            else:
                redirect = request.path
            backend = get_backend(backend, request, redirect)

            if not backend:
                return HttpResponseServerError(
                    "Incorrect authentication " + "service or service API settings not available!"
                )

            try:
                return func(request, backend, *args, **kwargs)
            except Exception, e:  # some error ocurred
                if RAISE_EXCEPTIONS:
                    raise
                backend_name = backend.AUTH_BACKEND.name

                log("error", unicode(e), exc_info=True, extra=dict(request=request))

                if "django.contrib.messages" in setting("INSTALLED_APPS"):
                    from django.contrib.messages.api import error

                    error(request, unicode(e), extra_tags=backend_name)
                else:
                    log("warn", "Messages framework not in place, some " + "errors have not been shown to the user.")

                url = backend_setting(backend, "SOCIAL_AUTH_BACKEND_ERROR_URL", LOGIN_ERROR_URL)
                return HttpResponseRedirect(url)
开发者ID:festlv,项目名称:django-social-auth,代码行数:30,代码来源:views.py

示例2: wrapper

        def wrapper(request, backend, *args, **kwargs):
            if redirect_name:
                redirect = reverse(redirect_name, args=(backend,))
            else:
                redirect = request.path
            backend = get_backend(backend, request, redirect)

            if not backend:
                return HttpResponseServerError('Incorrect authentication ' + \
                                               'service')

            RAISE_EXCEPTIONS = backend_setting(backend, 'SOCIAL_AUTH_RAISE_EXCEPTIONS', setting('DEBUG'))
            try:
                return func(request, backend, *args, **kwargs)
            except Exception, e:  # some error ocurred
                if RAISE_EXCEPTIONS:
                    raise
                log('error', unicode(e), exc_info=True, extra={
                    'request': request
                })

                mod, func_name = PROCESS_EXCEPTIONS.rsplit('.', 1)
                try:
                    process = getattr(import_module(mod), func_name,
                                      lambda *args: None)
                except ImportError:
                    pass
                else:
                    process(request, backend, e)

                url = backend_setting(backend, 'SOCIAL_AUTH_BACKEND_ERROR_URL',
                                      LOGIN_ERROR_URL)
                return HttpResponseRedirect(url)
开发者ID:1st,项目名称:django-social-auth,代码行数:33,代码来源:decorators.py

示例3: wrapper

        def wrapper(request, backend, *args, **kwargs):
            if redirect_name:
                redirect = reverse(redirect_name, args=(backend,))
            else:
                redirect = request.path
            backend = get_backend(backend, request, redirect)

            if not backend:
                return HttpResponseServerError('Incorrect authentication ' + \
                                               'service')

            try:
                return func(request, backend, *args, **kwargs)
            except Exception, e:  # some error ocurred
                backend_name = backend.AUTH_BACKEND.name
                msg = str(e)

                if 'django.contrib.messages' in settings.INSTALLED_APPS:
                    from django.contrib.messages.api import error
                    error(request, msg, extra_tags=backend_name)
                else:
                    if ERROR_KEY:  # store error in session
                        request.session[ERROR_KEY] = msg
                    if NAME_KEY:  # store the backend name for convenience
                        request.session[NAME_KEY] = backend_name
                return HttpResponseRedirect(BACKEND_ERROR_REDIRECT)
开发者ID:od-eon,项目名称:django-social-auth,代码行数:26,代码来源:views.py

示例4: wrapper

        def wrapper(request, backend, *args, **kwargs):
            if redirect_name:
                redirect = reverse(redirect_name, args=(backend,))
            else:
                redirect = request.path
            backend = get_backend(backend, request, redirect)

            if not backend:
                return HttpResponseServerError("Incorrect authentication " + "service")

            try:
                return func(request, backend, *args, **kwargs)
            except Exception, e:  # some error ocurred
                backend_name = backend.AUTH_BACKEND.name

                logger.error(unicode(e), exc_info=True, extra=dict(request=request))

                # Why!?
                msg = str(e)

                if "django.contrib.messages" in settings.INSTALLED_APPS:
                    from django.contrib.messages.api import error

                    error(request, msg, extra_tags=backend_name)
                else:
                    logger.warn("Messages framework not in place, some " + "errors have not been shown to the user.")
                return HttpResponseRedirect(BACKEND_ERROR_REDIRECT)
开发者ID:alexlovelltroy,项目名称:django-social-auth,代码行数:27,代码来源:views.py

示例5: wrapper

        def wrapper(request, backend, *args, **kwargs):
            if redirect_name:
                redirect = reverse(redirect_name, args=(backend,))
            else:
                redirect = request.path
            backend = get_backend(backend, request, redirect)

            if not backend:
                return HttpResponseServerError('Incorrect authentication ' + \
                                               'service')

            try:
                return func(request, backend, *args, **kwargs)
            except Exception, e:  # some error ocurred
                if setting('DEBUG'):
                    raise
                backend_name = backend.AUTH_BACKEND.name

                log('error', unicode(e), exc_info=True,
                    extra=dict(request=request))

                if 'django.contrib.messages' in setting('INSTALLED_APPS'):
                    from django.contrib.messages.api import error
                    error(request, unicode(e), extra_tags=backend_name)
                else:
                    log('warn', 'Messages framework not in place, some '+
                                'errors have not been shown to the user.')

                url = setting('SOCIAL_AUTH_BACKEND_ERROR_URL', LOGIN_ERROR_URL)
                return HttpResponseRedirect(url)
开发者ID:FrankBie,项目名称:django-social-auth,代码行数:30,代码来源:views.py

示例6: associate_complete

def associate_complete(request, backend):
    """Authentication complete process"""
    backend = get_backend(backend, request, request.path)
    if not backend:
        return HttpResponseServerError('Incorrect authentication service')
    backend.auth_complete(user=request.user)
    url = request.session.pop(REDIRECT_FIELD_NAME, '') or DEFAULT_REDIRECT
    return HttpResponseRedirect(url)
开发者ID:jess3,项目名称:django-social-auth,代码行数:8,代码来源:views.py

示例7: disconnect

def disconnect(request, backend):
    """Disconnects given backend from current logged in user."""
    backend = get_backend(backend, request, request.path)
    if not backend:
        return HttpResponseServerError("Incorrect authentication service")
    backend.disconnect(request.user)
    url = request.REQUEST.get(REDIRECT_FIELD_NAME, "") or DEFAULT_REDIRECT
    return HttpResponseRedirect(url)
开发者ID:statico,项目名称:django-social-auth,代码行数:8,代码来源:views.py

示例8: associate_complete

def associate_complete(request, backend):
    """Authentication complete process"""
    backend = get_backend(backend, request, request.path)
    if not backend:
        return HttpResponseServerError("Incorrect authentication service")
    backend.auth_complete(user=request.user)
    url = request.session.pop(REDIRECT_FIELD_NAME, "") or getattr(settings, "LOGIN_REDIRECT_URL", "")
    return HttpResponseRedirect(url)
开发者ID:orygens,项目名称:django-social-auth,代码行数:8,代码来源:views.py

示例9: disconnect

def disconnect(request, backend):
    """Disconnects given backend from current logged in user."""
    backend = get_backend(backend, request, request.path)
    if not backend:
        return HttpResponseServerError('Incorrect authentication service')
    backend.disconnect(request.user)
    url = request.REQUEST.get(REDIRECT_FIELD_NAME, '') or \
          getattr(settings, 'LOGIN_REDIRECT_URL', '')
    return HttpResponseRedirect(url)
开发者ID:justquick,项目名称:django-social-auth,代码行数:9,代码来源:views.py

示例10: disconnect

def disconnect(request, backend, association_id=None):
    """Disconnects given backend from current logged in user."""
    backend = get_backend(backend, request, request.path)
    if not backend:
        return HttpResponseServerError('Incorrect authentication service')
    backend.disconnect(request.user, association_id)
    url = request.REQUEST.get(REDIRECT_FIELD_NAME, '') or \
          DISCONNECT_REDIRECT_URL or \
          DEFAULT_REDIRECT
    return HttpResponseRedirect(url)
开发者ID:cid2105,项目名称:greek_gavel,代码行数:10,代码来源:views.py

示例11: wrapper

        def wrapper(request, backend, *args, **kwargs):
            if redirect_name:
                redirect = reverse(redirect_name, args=(backend,))
            else:
                redirect = request.path
            backend = get_backend(backend, request, redirect)

            if not backend:
                return HttpResponseServerError("Incorrect authentication " + "service")
            return func(request, backend, *args, **kwargs)
开发者ID:szaboat,项目名称:django-social-auth,代码行数:10,代码来源:views.py

示例12: wrapper

 def wrapper(request, backend, *args, **kwargs):
     if redirect_name:
         redirect = reverse(redirect_name, args=(backend,))
     else:
         redirect = request.path
     request.social_auth_backend = get_backend(backend, request,
                                               redirect)
     if request.social_auth_backend is None:
         raise WrongBackend(backend)
     return func(request, request.social_auth_backend, *args, **kwargs)
开发者ID:Kayle009,项目名称:sentry,代码行数:10,代码来源:decorators.py

示例13: auth_process

def auth_process(request, backend, complete_url_name, default_final_url):
    """Authenticate using social backend"""
    redirect = reverse(complete_url_name, args=(backend,))
    backend = get_backend(backend, request, redirect)
    if not backend:
        return HttpResponseServerError("Incorrect authentication service")
    request.session[REDIRECT_FIELD_NAME] = request.GET.get(REDIRECT_FIELD_NAME, default_final_url)
    if backend.uses_redirect:
        return HttpResponseRedirect(backend.auth_url())
    else:
        return HttpResponse(backend.auth_html(), content_type="text/html;charset=UTF-8")
开发者ID:orygens,项目名称:django-social-auth,代码行数:11,代码来源:views.py

示例14: complete

def complete(request, backend):
    """Authentication complete process"""
    backend = get_backend(backend, request, request.path)
    if not backend:
        return HttpResponseServerError("Incorrect authentication service")
    user = backend.auth_complete()
    if user and getattr(user, "is_active", True):
        login(request, user)
        url = request.session.pop(REDIRECT_FIELD_NAME, "") or getattr(settings, "LOGIN_REDIRECT_URL", "")
    else:
        url = getattr(settings, "LOGIN_ERROR_URL", settings.LOGIN_URL)
    return HttpResponseRedirect(url)
开发者ID:orygens,项目名称:django-social-auth,代码行数:12,代码来源:views.py

示例15: complete_process

def complete_process(request, backend):
    """Authentication complete process"""
    backend = get_backend(backend, request, request.path)
    if not backend:
        return HttpResponseServerError("Incorrect authentication service")

    try:
        user = backend.auth_complete()
    except ValueError, e:  # some Authentication error ocurred
        user = None
        error_key = getattr(settings, "SOCIAL_AUTH_ERROR_KEY", None)
        if error_key:  # store error in session
            request.session[error_key] = str(e)
开发者ID:statico,项目名称:django-social-auth,代码行数:13,代码来源:views.py


注:本文中的social_auth.backends.get_backend函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。