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.

hidden

Is it hidden? Defaults to True for file names starting with a period “.”

ctime

Created time.

mtime

Modified time.

classmethod get_module_permission()[source]

Get the module permission required for this model.

to_api_json(**options)[source]

Return json data for api methods.

classmethod build_elastic_query(term, multilingual=True)[source]

Build a search query for a term.

Parameters
  • term (str) – The search term.

  • multilingual (bool) – Set to False to search only the current language.

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.

get_thumbnail_path(size)[source]

Get absolute path to the thumbnail.

clear_thumbnails()[source]

Remove all cached thumbnails.

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
get_meta_data[source]

Read the EXIF data from the file.

Return type

list

Example of a result:

[{
    'category': 'category1',
    'tags': [{
        'tag': 'tag1',
        'value': 'value1'
    }, {
        'tag': 'tag2',
        'value': 'value2'
    }]
}, {
    'category': 'category2',
    'tags': [{
        'tag': 'tag1',
        'value': 'value1'
    }]
}]
image_dimensions[source]

Get the image pixel size as a (width, height) tuple.

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

xmm.models.File

exception DoesNotExist
exception MultipleObjectsReturned