Package oauth2client :: Module multistore_file :: Class _MultiStore
[hide private]
[frames] | no frames]

Class _MultiStore

source code


A file backed store for multiple credentials.

Nested Classes [hide private]
  _Storage
A Storage object that knows how to read/write a single credential.
Instance Methods [hide private]
 
__init__(self, filename, warn_on_readonly=True)
Initialize the class.
source code
 
_create_file_if_needed(self)
Create an empty file if necessary.
source code
 
_lock(self)
Lock the entire multistore.
source code
 
_unlock(self)
Release the lock on the multistore.
source code
 
_locked_json_read(self)
Get the raw content of the multistore file.
source code
 
_locked_json_write(self, data)
Write a JSON serializable data structure to the multistore.
source code
 
_refresh_data_cache(self)
Refresh the contents of the multistore.
source code
 
_decode_credential_from_json(self, cred_entry)
Load a credential from our JSON serialization.
source code
 
_write(self)
Write the cached data back out.
source code
 
_get_all_credential_keys(self)
Gets all the registered credential keys in the multistore.
source code
 
_get_credential(self, key)
Get a credential from the multistore.
source code
 
_update_credential(self, key, cred)
Update a credential and write the multistore.
source code
 
_delete_credential(self, key)
Delete a credential and write the multistore.
source code
 
_get_storage(self, key)
Get a Storage object to get/set a credential.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, filename, warn_on_readonly=True)
(Constructor)

source code 
Initialize the class.

This will create the file if necessary.

Decorators:
  • @util.positional(2)
Overrides: object.__init__

_create_file_if_needed(self)

source code 
Create an empty file if necessary.

This method will not initialize the file. Instead it implements a
simple version of "touch" to ensure the file has been created.

_locked_json_read(self)

source code 
Get the raw content of the multistore file.

The multistore must be locked when this is called.

Returns:
  The contents of the multistore decoded as JSON.

_locked_json_write(self, data)

source code 
Write a JSON serializable data structure to the multistore.

The multistore must be locked when this is called.

Args:
  data: The data to be serialized and written.

_refresh_data_cache(self)

source code 
Refresh the contents of the multistore.

The multistore must be locked when this is called.

Raises:
  NewerCredentialStoreError: Raised when a newer client has written the
    store.

_decode_credential_from_json(self, cred_entry)

source code 
Load a credential from our JSON serialization.

Args:
  cred_entry: A dict entry from the data member of our format

Returns:
  (key, cred) where the key is the key tuple and the cred is the
    OAuth2Credential object.

_write(self)

source code 
Write the cached data back out.

The multistore must be locked.

_get_all_credential_keys(self)

source code 
Gets all the registered credential keys in the multistore.

Returns:
  A list of dictionaries corresponding to all the keys currently registered

_get_credential(self, key)

source code 
Get a credential from the multistore.

The multistore must be locked.

Args:
  key: The key used to retrieve the credential

Returns:
  The credential specified or None if not present

_update_credential(self, key, cred)

source code 
Update a credential and write the multistore.

This must be called when the multistore is locked.

Args:
  key: The key used to retrieve the credential
  cred: The OAuth2Credential to update/set

_delete_credential(self, key)

source code 
Delete a credential and write the multistore.

This must be called when the multistore is locked.

Args:
  key: The key used to retrieve the credential

_get_storage(self, key)

source code 
Get a Storage object to get/set a credential.

This Storage is a 'view' into the multistore.

Args:
  key: The key used to retrieve the credential

Returns:
  A Storage object that can be used to get/set this cred