當前位置: 首頁>>代碼示例>>Python>>正文


Python storage.DjangoORMStorage方法代碼示例

本文整理匯總了Python中oauth2client.contrib.django_util.storage.DjangoORMStorage方法的典型用法代碼示例。如果您正苦於以下問題:Python storage.DjangoORMStorage方法的具體用法?Python storage.DjangoORMStorage怎麽用?Python storage.DjangoORMStorage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在oauth2client.contrib.django_util.storage的用法示例。


在下文中一共展示了storage.DjangoORMStorage方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_storage

# 需要導入模塊: from oauth2client.contrib.django_util import storage [as 別名]
# 或者: from oauth2client.contrib.django_util.storage import DjangoORMStorage [as 別名]
def get_storage(request):
    """ Gets a Credentials storage object provided by the Django OAuth2 Helper
    object.

    Args:
        request: Reference to the current request object.

    Returns:
       An :class:`oauth2.client.Storage` object.
    """
    storage_model = oauth2_settings.storage_model
    user_property = oauth2_settings.storage_model_user_property
    credentials_property = oauth2_settings.storage_model_credentials_property

    if storage_model:
        module_name, class_name = storage_model.rsplit('.', 1)
        module = importlib.import_module(module_name)
        storage_model_class = getattr(module, class_name)
        return storage.DjangoORMStorage(storage_model_class,
                                        user_property,
                                        request.user,
                                        credentials_property)
    else:
        # use session
        return dictionary_storage.DictionaryStorage(
            request.session, key=_CREDENTIALS_KEY) 
開發者ID:taers232c,項目名稱:GAMADV-XTD,代碼行數:28,代碼來源:__init__.py

示例2: maybe_authorize

# 需要導入模塊: from oauth2client.contrib.django_util import storage [as 別名]
# 或者: from oauth2client.contrib.django_util.storage import DjangoORMStorage [as 別名]
def maybe_authorize(request, redirect_url = False):
    storage = DjangoORMStorage(GoogleCredentials, 'id', request.user, 'credential')
    credential = storage.get()
    if credential is None or credential.invalid == True:
        flow = create_and_store_flow(request)
        authorize_url = flow.step1_get_authorize_url()
        if redirect_url:
            authorize_url = add_query_param(authorize_url, 'state', redirect_url)
        return (False, authorize_url)
    else:
        return (True, credential) 
開發者ID:CJWorkbench,項目名稱:cjworkbench,代碼行數:13,代碼來源:google_oauth.py

示例3: get_creds

# 需要導入模塊: from oauth2client.contrib.django_util import storage [as 別名]
# 或者: from oauth2client.contrib.django_util.storage import DjangoORMStorage [as 別名]
def get_creds(request):
    flow = jsonpickle.decode(request.session['flow'])
    credential = flow.step2_exchange(request.GET.get('code', False))
    storage = DjangoORMStorage(GoogleCredentials, 'id', request.user, 'credential')
    storage.put(credential)
    if request.GET.get('state', False):
        return redirect(unquote_plus(request.GET.get('state')))
    else:
        return HttpResponse(status=200) 
開發者ID:CJWorkbench,項目名稱:cjworkbench,代碼行數:11,代碼來源:google_oauth.py


注:本文中的oauth2client.contrib.django_util.storage.DjangoORMStorage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。