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


Python client.Storage方法代码示例

本文整理汇总了Python中oauth2client.client.Storage方法的典型用法代码示例。如果您正苦于以下问题:Python client.Storage方法的具体用法?Python client.Storage怎么用?Python client.Storage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oauth2client.client的用法示例。


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

示例1: __init__

# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import Storage [as 别名]
def __init__(self, model, key_name, property_name, cache=None, user=None):
    """Constructor for Storage.

    Args:
      model: db.Model or ndb.Model, model class
      key_name: string, key name for the entity that has the credentials
      property_name: string, name of the property that is a CredentialsProperty
        or CredentialsNDBProperty.
      cache: memcache, a write-through cache to put in front of the datastore.
        If the model you are using is an NDB model, using a cache will be
        redundant since the model uses an instance cache and memcache for you.
      user: users.User object, optional. Can be used to grab user ID as a
        key_name if no key name is specified.
    """
    if key_name is None:
      if user is None:
        raise ValueError('StorageByKeyName called with no key name or user.')
      key_name = user.user_id()

    self._model = model
    self._key_name = key_name
    self._property_name = property_name
    self._cache = cache 
开发者ID:mortcanty,项目名称:earthengine,代码行数:25,代码来源:appengine.py

示例2: __init__

# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import Storage [as 别名]
def __init__(self, session, model_class, key_name,
                 key_value, property_name):
        """Constructor for Storage.

        Args:
            session: An instance of :class:`sqlalchemy.orm.Session`.
            model_class: SQLAlchemy declarative mapping.
            key_name: string, key name for the entity that has the credentials
            key_value: key value for the entity that has the credentials
            property_name: A string indicating which property on the
                           ``model_class`` to store the credentials.
                           This property must be a
                           :class:`CredentialsType` column.
        """
        super(Storage, self).__init__()

        self.session = session
        self.model_class = model_class
        self.key_name = key_name
        self.key_value = key_value
        self.property_name = property_name 
开发者ID:Deltares,项目名称:aqua-monitor,代码行数:23,代码来源:sqlalchemy.py

示例3: __init__

# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import Storage [as 别名]
def __init__(self, model_class, key_name, key_value, property_name):
        """Constructor for Storage.

        Args:
            model: string, fully qualified name of db.Model model class.
            key_name: string, key name for the entity that has the credentials
            key_value: string, key value for the entity that has the
               credentials.
            property_name: string, name of the property that is an
                           CredentialsProperty.
        """
        super(DjangoORMStorage, self).__init__()
        self.model_class = model_class
        self.key_name = key_name
        self.key_value = key_value
        self.property_name = property_name 
开发者ID:fniephaus,项目名称:alfred-gmail,代码行数:18,代码来源:storage.py

示例4: locked_get

# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import Storage [as 别名]
def locked_get(self):
        """Retrieve stored credential from the Django ORM.

        Returns:
            oauth2client.Credentials retrieved from the Django ORM, associated
             with the ``model``, ``key_value``->``key_name`` pair used to query
             for the model, and ``property_name`` identifying the
             ``CredentialsProperty`` field, all of which are defined in the
             constructor for this Storage object.

        """
        query = {self.key_name: self.key_value}
        entities = self.model_class.objects.filter(**query)
        if len(entities) > 0:
            credential = getattr(entities[0], self.property_name)
            if getattr(credential, 'set_store', None) is not None:
                credential.set_store(self)
            return credential
        else:
            return None 
开发者ID:fniephaus,项目名称:alfred-gmail,代码行数:22,代码来源:storage.py

示例5: get_credential_storage

# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import Storage [as 别名]
def get_credential_storage(filename, client_id, user_agent, scope,
                           warn_on_readonly=True):
    """Get a Storage instance for a credential.

    Args:
        filename: The JSON file storing a set of credentials
        client_id: The client_id for the credential
        user_agent: The user agent for the credential
        scope: string or iterable of strings, Scope(s) being requested
        warn_on_readonly: if True, log a warning if the store is readonly

    Returns:
        An object derived from client.Storage for getting/setting the
        credential.
    """
    # Recreate the legacy key with these specific parameters
    key = {'clientId': client_id, 'userAgent': user_agent,
           'scope': util.scopes_to_string(scope)}
    return get_credential_storage_custom_key(
        filename, key, warn_on_readonly=warn_on_readonly) 
开发者ID:fniephaus,项目名称:alfred-gmail,代码行数:22,代码来源:multistore_file.py

示例6: get_credential_storage_custom_string_key

# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import Storage [as 别名]
def get_credential_storage_custom_string_key(filename, key_string,
                                             warn_on_readonly=True):
    """Get a Storage instance for a credential using a single string as a key.

    Allows you to provide a string as a custom key that will be used for
    credential storage and retrieval.

    Args:
        filename: The JSON file storing a set of credentials
        key_string: A string to use as the key for storing this credential.
        warn_on_readonly: if True, log a warning if the store is readonly

    Returns:
        An object derived from client.Storage for getting/setting the
        credential.
    """
    # Create a key dictionary that can be used
    key_dict = {'key': key_string}
    return get_credential_storage_custom_key(
        filename, key_dict, warn_on_readonly=warn_on_readonly) 
开发者ID:fniephaus,项目名称:alfred-gmail,代码行数:22,代码来源:multistore_file.py

示例7: get_credential_storage_custom_key

# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import Storage [as 别名]
def get_credential_storage_custom_key(filename, key_dict,
                                      warn_on_readonly=True):
    """Get a Storage instance for a credential using a dictionary as a key.

    Allows you to provide a dictionary as a custom key that will be used for
    credential storage and retrieval.

    Args:
        filename: The JSON file storing a set of credentials
        key_dict: A dictionary to use as the key for storing this credential.
                  There is no ordering of the keys in the dictionary. Logically
                  equivalent dictionaries will produce equivalent storage keys.
        warn_on_readonly: if True, log a warning if the store is readonly

    Returns:
        An object derived from client.Storage for getting/setting the
        credential.
    """
    multistore = _get_multistore(filename, warn_on_readonly=warn_on_readonly)
    key = _dict_to_tuple_key(key_dict)
    return multistore._get_storage(key) 
开发者ID:fniephaus,项目名称:alfred-gmail,代码行数:23,代码来源:multistore_file.py

示例8: __init__

# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import Storage [as 别名]
def __init__(self, model, key_name, property_name, cache=None, user=None):
        """Constructor for Storage.

        Args:
            model: db.Model or ndb.Model, model class
            key_name: string, key name for the entity that has the credentials
            property_name: string, name of the property that is a
                           CredentialsProperty or CredentialsNDBProperty.
            cache: memcache, a write-through cache to put in front of the
                   datastore. If the model you are using is an NDB model, using
                   a cache will be redundant since the model uses an instance
                   cache and memcache for you.
            user: users.User object, optional. Can be used to grab user ID as a
                  key_name if no key name is specified.
        """
        if key_name is None:
            if user is None:
                raise ValueError('StorageByKeyName called with no '
                                 'key name or user.')
            key_name = user.user_id()

        self._model = model
        self._key_name = key_name
        self._property_name = property_name
        self._cache = cache 
开发者ID:jmankoff,项目名称:data,代码行数:27,代码来源:appengine.py

示例9: __init__

# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import Storage [as 别名]
def __init__(self, model, key_name, property_name, cache=None, user=None):
        """Constructor for Storage.

        Args:
            model: db.Model or ndb.Model, model class
            key_name: string, key name for the entity that has the credentials
            property_name: string, name of the property that is a
                           CredentialsProperty or CredentialsNDBProperty.
            cache: memcache, a write-through cache to put in front of the
                   datastore. If the model you are using is an NDB model, using
                   a cache will be redundant since the model uses an instance
                   cache and memcache for you.
            user: users.User object, optional. Can be used to grab user ID as a
                  key_name if no key name is specified.
        """
        super(StorageByKeyName, self).__init__()

        if key_name is None:
            if user is None:
                raise ValueError('StorageByKeyName called with no '
                                 'key name or user.')
            key_name = user.user_id()

        self._model = model
        self._key_name = key_name
        self._property_name = property_name
        self._cache = cache 
开发者ID:Deltares,项目名称:aqua-monitor,代码行数:29,代码来源:appengine.py

示例10: __init__

# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import Storage [as 别名]
def __init__(self, filename):
        super(Storage, self).__init__(lock=threading.Lock())
        self._filename = filename 
开发者ID:fniephaus,项目名称:alfred-gmail,代码行数:5,代码来源:file.py

示例11: __init__

# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import Storage [as 别名]
def __init__(self, service_name, user_name):
        """Constructor.

        Args:
            service_name: string, The name of the service under which the
                          credentials are stored.
            user_name: string, The name of the user to store credentials for.
        """
        super(Storage, self).__init__(lock=threading.Lock())
        self._service_name = service_name
        self._user_name = user_name 
开发者ID:fniephaus,项目名称:alfred-gmail,代码行数:13,代码来源:keyring_storage.py

示例12: acquire_lock

# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import Storage [as 别名]
def acquire_lock(self):
            """Acquires any lock necessary to access this Storage.

            This lock is not reentrant.
            """
            self._multistore._lock() 
开发者ID:fniephaus,项目名称:alfred-gmail,代码行数:8,代码来源:multistore_file.py

示例13: release_lock

# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import Storage [as 别名]
def release_lock(self):
            """Release the Storage lock.

            Trying to release a lock that isn't held will result in a
            RuntimeError.
            """
            self._multistore._unlock() 
开发者ID:fniephaus,项目名称:alfred-gmail,代码行数:9,代码来源:multistore_file.py

示例14: locked_put

# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import Storage [as 别名]
def locked_put(self, credentials):
            """Write a credential.

            The Storage lock must be held when this is called.

            Args:
                credentials: Credentials, the credentials to store.
            """
            self._multistore._update_credential(self._key, credentials) 
开发者ID:fniephaus,项目名称:alfred-gmail,代码行数:11,代码来源:multistore_file.py

示例15: locked_delete

# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import Storage [as 别名]
def locked_delete(self):
            """Delete a credential.

            The Storage lock must be held when this is called.

            Args:
                credentials: Credentials, the credentials to store.
            """
            self._multistore._delete_credential(self._key) 
开发者ID:fniephaus,项目名称:alfred-gmail,代码行数:11,代码来源:multistore_file.py


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