File data model¶
Todo
Description…
-
class
File(*args, **values)[source]¶ -
path¶ Path to file.
-
missing¶ Is file deleted from storage?
-
filename¶ Actual filename including file extension.
-
size¶ Size of file in bytes.
-
mimetype¶ Mimetype of file.
-
isdir¶ Is it a directory?
-
title¶ Title of the file.
-
description¶ Text that makes sense to the user.
-
alt_text¶ Alternative text shown if frontend can’t load image.
Is it hidden? Defaults to True for file names starting with a period “.”
-
ctime¶ Created time.
-
mtime¶ Modified time.
-
classmethod
create_from_json(json)[source]¶ Create a new instance and set its properties with data from the given json dict.
-
classmethod
find_referencing_models()[source]¶ Find models that should be searched for references of this class.
-
update_from_json(json, compare_timestamps=True)[source]¶ Update the current instance with data from the given json dict.
-
classmethod
from_field_map(field_map, dataset, is_list=False)[source]¶ Find an instance by looking up fields in a referencing dataset.
-
basename¶ Get the filename without extension.
-
classmethod
iter_tree_nodes(parent, order_by=None)[source]¶ Iterate over the subnodes of a given parent.
- Parameters
parent (str) – Iterate over this node’s children
-
move_to(parent, pos=None)[source]¶ Move the specified node to a new parent.
TODO: This deletes any existing file in the target directory with the same name. This should be configurable.
- Parameters
parent (xmm.models.File) – Parent node
pos (int) – Ignored for files here.
-
get_meta_data[source]¶ Read the EXIF data from the file.
- Return type
Example of a result:
[{ 'category': 'category1', 'tags': [{ 'tag': 'tag1', 'value': 'value1' }, { 'tag': 'tag2', 'value': 'value2' }] }, { 'category': 'category2', 'tags': [{ 'tag': 'tag1', 'value': 'value1' }] }]
-
clone(**kwargs)[source]¶ Copy this file or folder.
- Parameters
path (str) – New path where the copy should be saved.
- Returns
A clone of this File.
- Return type
-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-