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.
-
-
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]¶ -
basename¶ The filename without extension.
-
classmethod
build_elastic_query(term, multilingual=True)[source]¶ Build a search query for a term.
Parameters:
-
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
-
classmethod
find_referencing_models()[source]¶ Find models that should be searched for references of this class.
-
classmethod
from_field_map(field_map, dataset, is_list=False)[source]¶ Find an instance by looking up fields in a referencing dataset.
-
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' }] }]
-
classmethod
iter_tree_nodes(parent, order_by=None)[source]¶ Generator that loops 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.
-
-
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
Model(*args, **values)[source]¶ -
title¶ Title of model
-
indices¶ Indices of model
-
mixins¶ Class mixins to apply on model
-
impl_objects(**kwargs)[source]¶ Return a filtered cursor for this definition’s implementation instances.
Parameters: kwargs – Additional kwargs passed to the query.
-
-
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()[source]¶ 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.
-