sams.storage.providers – Storage Providers¶
-
class
Provider(config_string: str)¶ A Provider instance
- Variables
config_string (str) – An entry from the
STORAGE_PROVIDERSconfig attributeentries (list[str]) – The entries as provided by the config string
module_name (str) – The name of the module, i.e. sams.storage.provider.mongo
class_name (str) – The name of the class, i.e. MongoGridFSProvider
module (module) – A reference to the loaded Python module
klass (type[SamsBaseStorageProvider]) – A reference to the loaded Python class
type_name (str) – The type_name as defined inside
self.klass
-
instance(config_string: str) → sams.storage.providers.base.SamsBaseStorageProvider¶ Retrieve the StorageProvider instance for this provider
- Parameters
config_string (str) – A string from any
STORAGE_DESTINATIONconfig attribute- Returns
A Storage Provider instance created from
self.klass, passing in the providedconfig_str- Return type
-
class
Providers¶ A mechanism to register storage providers with the system
This is used when bootstrapping the application to register storage providers from strings in the config.
Usage:
from sams.storage.providers import providers providers.register(...) providers.get(...) providers.exists(...) providers.all(...) providers.clear(...)
-
register(config_str: str)¶ Register a provider with the system
- Parameters
config_str (str) – The provider to add
-
get(name: str) → sams.storage.providers.Provider¶ Retrieve a registered storage provider by it’s name
- Parameters
name (str) – The name of the Provider
- Returns
Returns the Provider instance
- Return type
- Raises
sams_client.errors.SamsStorageProviderErrors.NotFound – if the provider is not found
-
exists(type_name: str) → bool¶ Check if a provider for the
type_nameexists- Parameters
type_name – The type name
- Returns
Trueif the provider is registered,Falseif not
-
all() → Dict[str, sams.storage.providers.Provider]¶ Returns all the registered providers
-
clear()¶ Clears all of the registered providers
-