core.models.StorageShard module¶
Module with the StorageShard model class.
- core.models.StorageShard.logger = <Logger core.models.StorageShard (INFO)>¶
The logger instance for this module.
- class core.models.StorageShard.StorageShard(*args, **kwargs)[source]¶
Bases:
ExportModelOperationsMixin('storage_shard'),TimestampModelMixin,ModelA database model to keep track of and manage the sharded storage’s status and structure.
Important
Use the custom methods to create new instances, never use
create()!- shard_directory_name¶
The name of the directory tracked by this entry. Unique.
- file_count¶
The number of files in this directory. 0 by default. Managed to not exceed
constance.get_config('STORAGE_MAX_FILES_PER_DIR').
- current¶
Flags whether this directory is the one where new data is being stored. False by default. There must only be one entry where this is set to True.
- __str__()[source]¶
Returns a string representation of the model data.
- Return type:
- Returns:
The string representation of the storage directory, using
pathand the state of the directory.
- save(*args, **kwargs)[source]¶
Extended :django:
django.models.Model.save()method.Safely creates the new directory tracked by the instance in the storage.
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- _meta = <Options for StorageShard>¶
- created¶
The datetime the model instance was created. Is set automatically.
- get_next_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=True, **kwargs)¶
- get_next_by_updated(*, field=<django.db.models.fields.DateTimeField: updated>, is_next=True, **kwargs)¶
- get_previous_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=False, **kwargs)¶
- get_previous_by_updated(*, field=<django.db.models.fields.DateTimeField: updated>, is_next=False, **kwargs)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- increment_file_count()[source]¶
Increments the
file_countwithin the limits ofconstance.get_config('STORAGE_MAX_FILES_PER_DIR').If the result exceeds this limit, creates a new storage directory via
_add_shard().- Return type:
- objects = <django.db.models.manager.Manager object>¶
- updated¶
The datetime the model instance entry was last updated. Is set automatically.
- decrement_file_count()[source]¶
Decrements the
file_countbut never below 0.- Return type:
- classmethod get_current_storage()[source]¶
Gets the current storage instance.
Creates one if none is found.
- Returns:
The currently used storage directory shard.
- Return type: