Item#
- class ansys.dynamicreporting.core.serverless.item.Item(*args, **kwargs)#
Bases:
BaseModelBase class for all persisted report items.
Items are typed containers of content linked to a
Sessionand aDataset. Concrete subclasses define the content validator andtypestring and are registered automatically so that_from_db()andcreate()can dispatch to the correct subclass based on the stored type.Methods
Item.add_tag(tag[, value])Add or update a single tag.
Item.as_dict([recursive])Serialize the model into a plain dictionary.
Item.create(**kwargs)Factory-style creation that dispatches to the correct subclass.
Delete this object from the database.
Item.filter(**kwargs)Return a collection of items, scoped by subclass type.
Item.find([query])Search for items using an ADR query string.
Item.get(**kwargs)Retrieve a single item instance, scoped by subclass type.
Item.get_iframe([width, height, context, ...])Return an inline iframe containing the rendered item.
Return the raw tag string stored on this object.
Reset the in-memory ORM state for this object.
Item.rem_tag(tag)Remove a tag by key, if it exists.
Item.remove_tag(tag)Alias for
rem_tag()for backwards compatibility.Item.render(*[, context, request])Render the item as HTML.
Item.save(**kwargs)Save the item, enforcing that session and dataset are persisted.
Item.set_tags(tag_str)Replace all tags with the given tag string.
Item.visualize([width, height, context, request])Display the rendered item inline.
Attributes
Payload content for the item.
Dataset associated with this item.
Database alias in which this object is stored.
Human-readable name for the item.
Whether this object has been successfully saved to the database.
Sequence index for ordering items within a dataset/session.
Session that owns this item.
Optional free-form source identifier for this item.
Tag string used to group and filter objects.
Item type identifier, normally set by subclasses.
Timestamp when the item was created.
Globally unique identifier for this object.
- content: ItemContent = None#
Payload content for the item.
- classmethod create(**kwargs)#
Factory-style creation that dispatches to the correct subclass.
When invoked on
Item, the caller must provide atypekeyword argument identifying the desired item type. For concrete subclasses,typeis injected automatically.
- classmethod filter(**kwargs)#
Return a collection of items, scoped by subclass type.
- Parameters:
- **kwargs
Key-value filters to find matching items. Eg:
source="Simulation 1"
- Returns:
ObjectSetCollection of matching items.
- classmethod find(query='')#
Search for items using an ADR query string.
For typed subclasses, an
i_typefilter is not allowed.
- classmethod get(**kwargs)#
Retrieve a single item instance, scoped by subclass type.
- get_iframe(width: int | float = 0, height: int | float = 0, *, context=None, request=None) str#
Return an inline iframe containing the rendered item.
- Parameters:
- width
intorfloat,optional Iframe width. By default, image width is used up to 1000 pixels, or 1000 pixels for other item types.
- height
intorfloat,optional Iframe height. By default, image height is used up to 400 pixels. Scenes default to 800 pixels and other item types to 400 pixels.
- context
dictorNone,optional Context dictionary passed to
render().- request
HttpRequestorNone,optional Django request object passed to
render(), if available.
- width
- Returns:
strString-like iframe markup that rich display frontends render as HTML.
- save(**kwargs)#
Save the item, enforcing that session and dataset are persisted.
- Parameters:
- **kwargs
Keyword arguments forwarded to the database
savemethod of the underlying ORM instance. For eg: Theusingargument can be used to select the target database alias.
- Raises:
ADRExceptionIf the session or dataset is missing.
Session.NotSavedIf the associated session has not been saved.
Dataset.NotSavedIf the associated dataset has not been saved.
- visualize(width: int | float = 0, height: int | float = 0, *, context=None, request=None) None#
Display the rendered item inline.
- Parameters:
- width
intorfloat,optional Iframe width. When set to zero, the width is derived as described by
get_iframe().- height
intorfloat,optional Iframe height. When set to zero, the height is derived as described by
get_iframe().- context
dictorNone,optional Context dictionary passed to
render().- request
HttpRequestorNone,optional Django request object passed to
render(), if available.
- width
- Raises:
RuntimeErrorIf IPython is unavailable.