XMM Core Models¶
-
class
Attribute(*args, **values)[source]¶ An attribute used by Models, dynamic model definitions, Nodes, Pages etc.
-
key¶ Unique. Visible in frontend under “key” symbol.
-
label¶ Name tag that makes sense to the user.
-
description¶ Description that makes sense to the user.
-
field_class¶ Defines attribute field type and its behaviour.
-
metadata¶ Additional info like if it references a model or is choice-based.
-
default¶ A default value.
-
nullable¶ Flag, if true, this attribute’s value can be NULL
Never show this attribute in UI
-
multilingual¶ Is multilingual
-
multivalue¶ Can have list of values.
-
mutable¶ Changeable in frontend.
-
unit¶ Units that values of this attribute have.
-
use_si_prefixes¶ Automatically show metric units with their largest suitable SI prefix (e.g. 52319 shows as 52k)
-
fields¶ Meta-Attribute fields
-
classmethod
post_delete(sender, document, **kwargs)[source]¶ Remove all values stored in the database belonging to this attribute.
-
to_dict(**data)[source]¶ Get a dict representation suitable for JSON of this instance.
- Parameters
data – additional items to be added.
-
classmethod
find_referencing_models()[source]¶ Find models that should be searched for references of this class.
-
find_dynamic_usages()[source]¶ Find usages of this attribute in other dynamic models.
- Returns
a list of models (definitions) where this attribute is referenced.
-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
-
class
AttributeGroup(*args, **kwargs)[source]¶ A model may have attributes grouped together.
-
key¶ Unique. Visible in frontend under “key” symbol.
-
label¶ Name tag that makes sense to the user.
-
description¶ Description that makes sense to the user.
-
attributes¶ List of attributes in this group.
-
-
class
ModelReference(*args, **kwargs)[source]¶ -
model¶ References model
-
key¶ Unique. Visible in frontend under “key” symbol.
-
label¶ Name tag that makes sense to the user.
-
label_plural¶ Plural name tag that makes sense to the user.
-
disallow_sorting¶ Flag to disallow “manual” sorting of the referenced datasets
-
-
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¶
-
-
class
Index(*args, **kwargs)[source]¶ Index class that defines database level indexes for dynamic models.
-
key¶ Unique. Visible in frontend under “key” symbol.
-
type¶ What kind of index?, ‘index’ or ‘unique’.
-
attributes¶ List of keys of attributes that are part of the index.
-
-
class
Link(*args, **kwargs)[source]¶ -
model¶ Model identifier; either a string or ObjectId
-
reference¶ Object id of document that is referenced.
-
is_url¶ Is it a URL?
-
url¶ URL if it is a url.
-
urlsuffix¶ Optional text to append to the URL.
-
title¶ Title of Link that can be multilingual.
-
target¶ HTML target (e.g., ‘_blank’)
-
anchor¶ HTML anchor (<a href=”…” id={{ anchor }}>)
-
class_name¶ CSS class (<a href=”…” class={{ class_name }}>)
-
-
class
Model(*args, **values)[source]¶ -
title¶ Title of model
-
indices¶ Indices of model
-
mixins¶ Class mixins to apply on model
-
classmethod
get_read_permission(obj_id=None)[source]¶ Get read permission.
Reading Model definitions is always allowed.
-
to_dict(**data)[source]¶ Get a dict representation suitable for JSON of this instance.
- Parameters
data – additional items to be added.
-
impl_objects(**kwargs)[source]¶ Return a filtered cursor for this definition’s implementation instances.
- Parameters
kwargs – Additional kwargs passed to the query.
-
classmethod
find_referencing_models()[source]¶ Find models that should be searched for references of this class.
-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
-
class
Node(*args, **values)[source]¶ A node implements a node type.
A single node may define any number of additional attributes, which will be available on every linked model instance. Attribute selection is only available if the node’s type has
has_classificationset to True.-
type_field= 'nodetype'¶ Needed for dynamic models to know that this thing is instance of nodetype.
-
parent¶ Page that is parent of this page.
-
pos¶ Represents position of page in tree.
-
nodetype¶ References type of this node.
-
classmethod
get_impl_class() → type[source]¶ Get implementation class.
A node may reference datasets as a classification. In this case the impl_class is the node itself.
-
classmethod
find_referencing_models()[source]¶ Find models that should be searched for references of this class.
-
classmethod
create_from_json(json)[source]¶ Create a new instance and set its properties with data from the given json dict.
-
update_from_json(json, compare_timestamps=True)[source]¶ Update the current instance with data from the given json dict.
-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-
-
class
Tag(*args, **values)[source]¶ Tags will be used for everything in the XMM. But first only for media etc.
-
key¶ Unique key of the tag.
-
classmethod
find_referencing_models()[source]¶ Find models that should be searched for references of this class.
Should yield pairs of [(model, filter_key)].
-
exception
DoesNotExist¶
-
exception
MultipleObjectsReturned¶
-