cdh.files.db.wrappers module

class cdh.files.db.wrappers.FileWrapper(file_instance, field, original_filename)[source]

Bases: File

DEFAULT_CHUNK_SIZE = 65536
__init__(file_instance, field, original_filename)[source]
close()[source]
property closed
property content_type
property created_by
property created_on
delete(save=True, force=False)[source]

Deletes the file on disk. If save = True, the metadata object will also be deleted. Note: only delete the metadata object if no other DB object is referencing it, otherwise you’ll get nasty Integrity errors!

Parameters
  • save – Whether to also delete the metadata in the DB, defaults to True

  • force – Whether to force a deletion if multiple DB objects still refer to it, defaults to False

property field
property file
get_content_type_display()[source]

Shows the label of the content_type. See get_FOO_display() for more information.

property id
property modified_on
property name
property name_on_disk
open(mode='rb')[source]
property path
property pk
save(content=None, original_filename=None)[source]
property size
property url
property uuid
class cdh.files.db.wrappers.PrivateCacheMixin(*args, **kwargs)[source]

Bases: object

__init__(*args, **kwargs)[source]
cache_value(key, value)[source]
get_cached_value(key)[source]
invalidate_cache_value(key)[source]
invalidate_caches()[source]
is_cached(key)[source]
class cdh.files.db.wrappers.TrackedFileWrapper(manager: Manager, instance, field: TrackedFileField)[source]

Bases: PrivateCacheMixin

__init__(manager: Manager, instance, field: TrackedFileField)[source]
add(file: Union[UUID, FileWrapper, BaseFile, int, str]) None[source]
property all
property current_file: Optional[FileWrapper]

Tries to retrieve the file representing the ‘current’ value of this field.

delete(file: Union[UUID, FileWrapper, BaseFile, int, str]) None[source]
delete_all() None[source]

Delete all files currently tracked

set_as_current(file: Union[UUID, FileWrapper, BaseFile, int, str]) None[source]