API Reference

Configuration Options

IDOM provides a series of configuration options that can be set using environment variables or, for those which allow it, a programatic interface.

idom.config.IDOM_DEBUG_MODE = Option(IDOM_DEBUG_MODE=False)

This immutable option turns on/off debug mode

The string values 1 and 0 are mapped to True and False respectively.

When debug is on, extra validation measures are applied that negatively impact performance but can be used to catch bugs. Additionally, the default log level for IDOM is set to DEBUG.

idom.config.IDOM_WED_MODULES_DIR = Option(IDOM_WED_MODULES_DIR=PosixPath('/tmp/tmpvsucrq3l'))

The location IDOM will use to store its client application

This directory MUST be treated as a black box. Downstream applications MUST NOT assume anything about the structure of this directory see idom.web.module for a set of publically available APIs for working with the client.

idom.config.IDOM_FEATURE_INDEX_AS_DEFAULT_KEY = Option(IDOM_FEATURE_INDEX_AS_DEFAULT_KEY=False)

Use the index of elements/components amongst their siblings as the default key.

In a future release this flag’s default value will be set to true, and after that, this flag will be removed entirely and the indices will always be the default key.

For more information on changes to this feature flag see: https://github.com/idom-team/idom/issues/351

Component

idom.core.component.component(function)[source]

A decorator for defining an Component.

Parameters

function (Callable[[...], Union[idom.core.proto.ComponentType, idom.core.proto.VdomDict]]) – The function that will render a VdomDict.

Return type

Callable[[…], Component]

class idom.core.component.Component(function, key, args, kwargs)[source]

Bases: object

An object for rending component models.

Parameters
  • function (Callable[..., Union[ComponentType, VdomDict]]) –

  • key (Optional[Any]) –

  • args (Tuple[Any, ...]) –

  • kwargs (Dict[str, Any]) –

Return type

None

Dispatchers

async idom.core.dispatcher.dispatch_single_view(layout, send, recv)[source]

Run a dispatch loop for a single view instance

Parameters
Return type

None

idom.core.dispatcher.create_shared_view_dispatcher(layout)[source]

Enter a dispatch context where all subsequent view instances share the same state

Parameters

layout (idom.core.proto.LayoutType[idom.core.layout.LayoutUpdate, idom.core.layout.LayoutEvent]) –

Return type

AsyncIterator[Callable[[Callable[[VdomJsonPatch], Awaitable[None]], Callable[[], Awaitable[idom.core.layout.LayoutEvent]]], Future[None]]]

idom.core.dispatcher.ensure_shared_view_dispatcher_future(layout)[source]

Ensure the future of a dispatcher created by create_shared_view_dispatcher()

Parameters

layout (LayoutType[LayoutUpdate, LayoutEvent]) –

Return type

Tuple[Future[None], SharedViewDispatcher]

async idom.core.dispatcher.render_json_patch(layout)[source]

Render a class:VdomJsonPatch from a layout

Parameters

layout (idom.core.proto.LayoutType[idom.core.layout.LayoutUpdate, Any]) –

Return type

idom.core.dispatcher.VdomJsonPatch

class idom.core.dispatcher.VdomJsonPatch(path, changes)[source]

Bases: tuple

An object describing an update to a Layout in the form of a JSON patch

Parameters
  • path (str) –

  • changes (List[Dict[str, Any]]) –

path: str

The path where changes should be applied

changes: List[Dict[str, Any]]

A list of JSON patches to apply at the given path

apply_to(model)[source]

Return the model resulting from the changes in this update

Parameters

model (idom.core.proto.VdomJson) –

Return type

idom.core.proto.VdomJson

classmethod create_from(update)[source]

Return a patch given an layout update

Parameters

update (idom.core.layout.LayoutUpdate) –

Return type

idom.core.dispatcher.VdomJsonPatch

Events

idom.core.events.event(stop_propagation=False, prevent_default=False)[source]

A decorator for constructing an EventHandler.

While you’re always free to add callbacks by assigning them to an element’s attributes

element = idom.html.button({"onClick": my_callback})

You may want the ability to prevent the default action associated with the event from taking place, or stoping the event from propagating up the DOM. This decorator allows you to add that functionality to your callbacks.

@event(stop_propagation=True, prevent_default=True)
def my_callback(*data):
    ...

element = idom.html.button({"onClick": my_callback})
Parameters
  • function – A function or coroutine responsible for handling the event.

  • stop_propagation (bool) – Block the event from propagating further up the DOM.

  • prevent_default (bool) – Stops the default actional associate with the event from taking place.

Return type

Callable[[Callable[[…], Any]], idom.core.events.EventHandler]

class idom.core.events.EventHandler(function, stop_propagation=False, prevent_default=False, target=None)[source]

Bases: object

Turn a function or coroutine into an event handler

Parameters
  • function (EventHandlerFunc) – The function or coroutine which handles the event.

  • stop_propagation (bool) – Block the event from propagating further up the DOM.

  • prevent_default (bool) – Stops the default action associate with the event from taking place.

  • target (Optional[str]) – A unique identifier for this event handler (auto-generated by default)

Return type

None

idom.core.events.to_event_handler_function(function, positional_args=True)[source]

Make a EventHandlerFunc from a function or coroutine

Parameters
  • function (Callable[[...], Any]) – A function or coroutine accepting a number of positional arguments.

  • positional_args (bool) – Whether to pass the event parameters a positional args or as a list.

Return type

idom.core.proto.EventHandlerFunc

idom.core.events.merge_event_handlers(event_handlers)[source]

Merge multiple event handlers into one

Raises a ValueError if any handlers have conflicting stop_propagation or prevent_default attributes.

Parameters

event_handlers (Sequence[idom.core.proto.EventHandlerType]) –

Return type

idom.core.proto.EventHandlerType

idom.core.events.merge_event_handler_funcs(functions)[source]

Make one event handler function from many

Parameters

functions (Sequence[idom.core.proto.EventHandlerFunc]) –

Return type

idom.core.proto.EventHandlerFunc

Hooks

idom.core.hooks.use_state(initial_value)[source]

See the full Use State docs for details

Parameters

initial_value (Union[idom.core.hooks._StateType, Callable[[], idom.core.hooks._StateType]]) – Defines the initial value of the state. A callable (accepting no arguments) can be used as a constructor function to avoid re-creating the initial value on each render.

Returns

A tuple containing the current state and a function to update it.

Return type

Tuple[idom.core.hooks._StateType, Callable[[Union[idom.core.hooks._StateType, Callable[[idom.core.hooks._StateType], idom.core.hooks._StateType]]], None]]

idom.core.hooks.use_effect(function: None = None, args: Optional[Sequence[Any]] = None) Callable[[Union[Callable[[], Optional[Callable[[], None]]], Callable[[], Awaitable[Optional[Callable[[], None]]]]]], None][source]
idom.core.hooks.use_effect(function: Union[Callable[[], Optional[Callable[[], None]]], Callable[[], Awaitable[Optional[Callable[[], None]]]]], args: Optional[Sequence[Any]] = None) None

See the full Use Effect docs for details

Parameters
  • function – Applies the effect and can return a clean-up function

  • args – Dependencies for the effect. If provided the effect will only trigger when these args change.

Returns

If not function is provided, a decorator. Otherwise None.

idom.core.hooks.use_reducer(reducer, initial_value)[source]

See the full Use Reducer docs for details

Parameters
  • reducer (Callable[[idom.core.hooks._StateType, idom.core.hooks._ActionType], idom.core.hooks._StateType]) – A function which applies an action to the current state in order to produce the next state.

  • initial_value (idom.core.hooks._StateType) – The initial state value (same as for use_state())

Returns

A tuple containing the current state and a function to change it with an action

Return type

Tuple[idom.core.hooks._StateType, Callable[[idom.core.hooks._ActionType], None]]

idom.core.hooks.use_callback(function: None = None, args: Optional[Sequence[Any]] = None) Callable[[idom.core.hooks._CallbackFunc], idom.core.hooks._CallbackFunc][source]
idom.core.hooks.use_callback(function: idom.core.hooks._CallbackFunc, args: Optional[Sequence[Any]] = None) idom.core.hooks._CallbackFunc

See the full Use Callback docs for details

Parameters
  • function – the function whose identity will be preserved

  • args – The identity the function will be udpated when these args change.

Returns

The current function

idom.core.hooks.use_ref(initial_value)[source]

See the full Use State docs for details

Parameters

initial_value (idom.core.hooks._StateType) – The value initially assigned to the reference.

Returns

A Ref object.

Return type

idom.utils.Ref[idom.core.hooks._StateType]

idom.core.hooks.use_memo(function: None = None, args: Optional[Sequence[Any]] = None) idom.core.hooks._LambdaCaller[source]
idom.core.hooks.use_memo(function: Callable[[], idom.core.hooks._StateType], args: Optional[Sequence[Any]] = None) idom.core.hooks._StateType

See the full Use Memo docs for details

Parameters
  • function – The function to be memoized.

  • args – The function will be recomputed when these args change.

Returns

The current state

Layout

class idom.core.layout.LayoutUpdate(path, old, new)[source]

Bases: tuple

A change to a view as a result of a Layout.render()

Parameters
path: str

A “/” delimited path to the element from the root of the layout

old: Optional[idom.core.proto.VdomJson]

The old state of the layout

new: idom.core.proto.VdomJson

The new state of the layout

class idom.core.layout.LayoutEvent(target, data)[source]

Bases: tuple

An event that should be relayed to its handler by Layout.deliver()

Parameters
  • target (str) –

  • data (List[Any]) –

target: str

The ID of the event handler.

data: List[Any]

A list of event data passed to the event handler.

class idom.core.layout.Layout(root)[source]

Bases: object

Responsible for “rendering” components. That is, turning them into VDOM.

Parameters

root (ComponentType) –

Return type

None

async deliver(event)[source]

Dispatch an event to the targeted handler

Parameters

event (idom.core.layout.LayoutEvent) –

Return type

None

async render()[source]

Await the next available render. This will block until a component is updated

Return type

idom.core.layout.LayoutUpdate

Core Interfaces

idom.core.proto.ComponentConstructor

Simple function returning a new component

alias of Callable[[…], ComponentType]

class idom.core.proto.ComponentType(*args, **kwargs)[source]

Bases: Protocol

The expected interface for all component-like objects

key: Optional[Any]

An identifier which is unique amongst a component’s immediate siblings

render()[source]

Render the component’s VdomDict.

Return type

idom.core.proto.VdomDict

class idom.core.proto.LayoutType(*args, **kwargs)[source]

Bases: Protocol[idom.core.proto._Render, idom.core.proto._Event]

Renders and delivers, updates to views and events to handlers, respectively

async render()[source]

Render an update to a view

Return type

idom.core.proto._Render

async deliver(event)[source]

Relay an event to its respective handler

Parameters

event (idom.core.proto._Event) –

Return type

None

idom.core.proto.VdomAttributes

Describes the attributes of a VdomDict

alias of Mapping[str, Any]

idom.core.proto.VdomChild

A single child element of a VdomDict

alias of Union[idom.core.proto.ComponentType, VdomDict, str]

idom.core.proto.VdomChildren

Describes a series of VdomChild elements

alias of Sequence[Union[idom.core.proto.ComponentType, VdomDict, str]]

idom.core.proto.VdomAttributesAndChildren

Useful for the *attributes_and_children parameter in idom.core.vdom.vdom()

alias of Union[Mapping[str, Any], Iterable[Union[idom.core.proto.ComponentType, VdomDict, str]]]

class idom.core.proto.VdomDict(_typename, _fields=None, /, **kwargs)[source]

Bases: dict

A VDOM dictionary

class idom.core.proto.ImportSourceDict(_typename, _fields=None, /, **kwargs)[source]

Bases: dict

class idom.core.proto.VdomJson(_typename, _fields=None, /, **kwargs)[source]

Bases: dict

A JSON serializable form of VdomDict matching the VDOM_JSON_SCHEMA

idom.core.proto.EventHandlerMapping

A generic mapping between event names to their handlers

alias of Mapping[str, EventHandlerType]

idom.core.proto.EventHandlerDict

A dict mapping between event names to their handlers

alias of Dict[str, EventHandlerType]

class idom.core.proto.EventHandlerFunc(*args, **kwargs)[source]

Bases: Protocol

A coroutine which can handle event data

class idom.core.proto.EventHandlerType(*args, **kwargs)[source]

Bases: Protocol

Defines a handler for some event

prevent_default: bool

Whether to block the event from propagating further up the DOM

stop_propagation: bool

Stops the default action associate with the event from taking place.

function: idom.core.proto.EventHandlerFunc

A coroutine which can respond to an event and its data

target: Optional[str]

Typically left as None except when a static target is useful.

When testing, it may be useful to specify a static target ID so events can be triggered programatically.

Note

When None, it is left to a LayoutType to auto generate a unique ID.

VDOM Constructors

idom.core.vdom.VDOM_JSON_SCHEMA = {'$ref': '#/definitions/element', '$schema': 'http://json-schema.org/draft-07/schema', 'definitions': {'element': {'dependentSchemas': {'error': {'properties': {'tagName': {'maxLength': 0}}}}, 'properties': {'attributes': {'type': 'object'}, 'children': {'$ref': '#/definitions/elementChildren'}, 'error': {'type': 'string'}, 'eventHandlers': {'$ref': '#/definitions/elementEventHandlers'}, 'importSource': {'$ref': '#/definitions/importSource'}, 'key': {'type': 'string'}, 'tagName': {'type': 'string'}}, 'required': ['tagName'], 'type': 'object'}, 'elementChildren': {'items': {'$ref': '#/definitions/elementOrString'}, 'type': 'array'}, 'elementEventHandlers': {'patternProperties': {'.*': {'$ref': '#/definitions/eventHander'}}, 'type': 'object'}, 'elementOrString': {'if': {'type': 'object'}, 'then': {'$ref': '#/definitions/element'}, 'type': ['object', 'string']}, 'eventHander': {'properties': {'preventDefault': {'type': 'boolean'}, 'stopPropagation': {'type': 'boolean'}, 'target': {'type': 'string'}}, 'required': ['target'], 'type': 'object'}, 'importSource': {'properties': {'fallback': {'if': {'not': {'type': 'null'}}, 'then': {'$ref': '#/definitions/elementOrString'}, 'type': ['object', 'string', 'null']}, 'source': {'type': 'string'}, 'sourceType': {'enum': ['URL', 'NAME']}, 'unmountBeforeUpdate': {'type': 'boolean'}}, 'required': ['source'], 'type': 'object'}}}

JSON Schema describing serialized VDOM - see VDOM for more info

idom.core.vdom.validate_vdom_json(value)[source]

Validate serialized VDOM - see VDOM_JSON_SCHEMA for more info

Parameters

value (Any) –

Return type

idom.core.proto.VdomJson

idom.core.vdom.is_vdom(value)[source]

Return whether a value is a VdomDict

This employs a very simple heuristic - something is VDOM if:

  1. It is a dict instance

  2. It contains the key "tagName"

  3. The value of the key "tagName" is a string

Note

Performing an isinstance(value, VdomDict) check is too restrictive since the user would be forced to import VdomDict every time they needed to declare a VDOM element. Giving the user more flexibility, at the cost of this check’s accuracy, is worth it.

Parameters

value (Any) –

Return type

bool

idom.core.vdom.vdom(tag, *attributes_and_children, key='', event_handlers=None, import_source=None)[source]

A helper function for creating VDOM dictionaries.

Parameters
  • tag (str) – The type of element (e.g. ‘div’, ‘h1’, ‘img’)

  • attributes_and_children (Union[Mapping[str, Any], Iterable[Union[idom.core.proto.ComponentType, VdomDict, str]]]) – An optional attribute mapping followed by any number of children or iterables of children. The attribute mapping must precede the children, or children which will be merged into their respective parts of the model.

  • key (str) – A string idicating the identity of a particular element. This is significant to preserve event handlers across updates - without a key, a re-render would cause these handlers to be deleted, but with a key, they would be redirected to any newly defined handlers.

  • event_handlers (Optional[Mapping[str, EventHandlerType]]) – Maps event types to coroutines that are responsible for handling those events.

  • import_source (Optional[idom.core.proto.ImportSourceDict]) – (subject to change) specifies javascript that, when evaluated returns a React component.

Return type

idom.core.proto.VdomDict

idom.core.vdom.make_vdom_constructor(tag, allow_children=True)[source]

Return a constructor for VDOM dictionaries with the given tag name.

The resulting callable will have the same interface as vdom() but without its first tag argument.

Parameters
  • tag (str) –

  • allow_children (bool) –

Return type

idom.core.vdom._VdomDictConstructor

Standard HTML Elements

External sources

Content Sectioning

Text Content

Inline Text Semantics

Image and video

Table Content

Forms

Interactive Elements

Return a new <link/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.style(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <style/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.address(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <address/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.article(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <article/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.aside(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <aside/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.footer(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <footer/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.h1(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <h1/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.h2(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <h2/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.h3(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <h3/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.h4(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <h4/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.h5(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <h5/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.h6(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <h6/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.header(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <header/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.hgroup(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <hgroup/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.nav(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <nav/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.section(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <section/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.blockquote(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <blockquote/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.dd(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <dd/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.div(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <div/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.dl(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <dl/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.dt(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <dt/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.figcaption(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <figcaption/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.figure(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <figure/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.hr(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <hr/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.li(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <li/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.ol(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <ol/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.p(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <p/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.pre(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <pre/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.ul(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <ul/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.a(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <a/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.abbr(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <abbr/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.b(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <b/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.br(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <br/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.cite(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <cite/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.code(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <code/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.data(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <data/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.em(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <em/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.i(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <i/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.kbd(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <kbd/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.mark(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <mark/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.q(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <q/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.s(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <s/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.samp(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <samp/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.small(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <small/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.span(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <span/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.strong(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <strong/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.sub(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <sub/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.sup(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <sup/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.time(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <time/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.u(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <u/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.var(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <var/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.img(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <img/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.audio(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <audio/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.video(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <video/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.source(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <source/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.caption(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <caption/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.col(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <col/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.colgroup(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <colgroup/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.table(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <table/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.tbody(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <tbody/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.td(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <td/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.tfoot(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <tfoot/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.th(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <th/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.thead(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <thead/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.tr(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <tr/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.meter(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <meter/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.output(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <output/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.progress(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <progress/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.input(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <input/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.button(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <button/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.label(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <label/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.fieldset(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <fieldset/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.legend(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <legend/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.details(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <details/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.dialog(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <dialog/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.menu(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <menu/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.menuitem(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <menuitem/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

idom.html.summary(*attributes_and_children, key='', event_handlers=None, import_source=None)

Return a new <summary/> VdomDict element

Parameters
Return type

idom.core.proto.VdomDict

Logging

idom.log.logging_config_defaults()[source]

Get default logging configuration

Return type

Any

FastAPI Servers

class idom.server.fastapi.Config(*args, **kwargs)[source]

Bases: dict

Config for FastApiRenderServer

idom.server.fastapi.PerClientStateServer(constructor, config=None, app=None)[source]

Return a FastApiServer where each client has its own state.

Implements the ServerFactory protocol

Parameters
  • constructor (Callable[[...], ComponentType]) – A component constructor

  • config (Optional[idom.server.fastapi.Config]) – Options for configuring server behavior

  • app (Optional[fastapi.applications.FastAPI]) – An application instance (otherwise a default instance is created)

Return type

idom.server.fastapi.FastApiServer

idom.server.fastapi.SharedClientStateServer(constructor, config=None, app=None)[source]

Return a FastApiServer where each client shares state.

Implements the ServerFactory protocol

Parameters
  • constructor (Callable[[...], ComponentType]) – A component constructor

  • config (Optional[idom.server.fastapi.Config]) – Options for configuring server behavior

  • app (Optional[fastapi.applications.FastAPI]) – An application instance (otherwise a default instance is created)

Return type

idom.server.fastapi.FastApiServer

class idom.server.fastapi.FastApiServer(app)[source]

Bases: object

A thin wrapper for running a FastAPI application

See idom.server.proto.Server for more info

Parameters

app (FastAPI) –

Return type

None

Flask Servers

class idom.server.flask.Config(_typename, _fields=None, /, **kwargs)[source]

Bases: dict

Render server config for FlaskRenderServer

idom.server.flask.PerClientStateServer(constructor, config=None, app=None)[source]

Return a FlaskServer where each client has its own state.

Implements the ServerFactory protocol

Parameters
  • constructor (Callable[[...], ComponentType]) – A component constructor

  • config (Optional[idom.server.flask.Config]) – Options for configuring server behavior

  • app (Optional[flask.app.Flask]) – An application instance (otherwise a default instance is created)

Return type

idom.server.flask.FlaskServer

class idom.server.flask.FlaskServer(app)[source]

Bases: object

A thin wrapper for running a Flask application

See idom.server.proto.Server for more info

Parameters

app (Flask) –

Return type

None

Server Prefabs

idom.server.prefab.run(component, server_type=None, host='127.0.0.1', port=None, server_config=None, run_kwargs=None, app=None, daemon=False)[source]

A utility for quickly running a render server with minimal boilerplate

Parameters
  • component (Callable[[...], ComponentType]) – The root of the view.

  • server_type (Optional[idom.server.proto.ServerFactory[idom.server.prefab._App, idom.server.prefab._Config]]) – What server to run. Defaults to a builtin implementation if available.

  • host (str) – The host string.

  • port (Optional[int]) – The port number. Defaults to a dynamically discovered available port.

  • server_config (Optional[Any]) – Options passed to configure the server.

  • run_kwargs (Optional[Dict[str, Any]]) – Keyword arguments passed to the run() or run_in_thread() methods of the server depending on whether daemon is set or not.

  • app (Optional[Any]) – Register the server to an existing application and run that.

  • daemon (bool) – Whether the server should be run in a daemon thread.

Returns

The server instance. This isn’t really useful unless the server is spawned as a daemon. Otherwise this function blocks until the server has stopped.

Return type

idom.server.proto.Server[idom.server.prefab._App]

idom.server.prefab.multiview_server(server_type=None, host='127.0.0.1', port=None, server_config=None, run_kwargs=None, app=None)[source]

Set up a server where views can be dynamically added.

In other words this allows the user to work with IDOM in an imperative manner. Under the hood this uses the idom.widgets.multiview() function to add the views on the fly.

Parameters
  • server – The server type to start up as a daemon

  • host (str) – The server hostname

  • port (Optional[int]) – The server port number

  • server_config (Optional[idom.server.prefab._Config]) – Value passed to ServerFactory()

  • run_kwargs (Optional[Dict[str, Any]]) – Keyword args passed to run_in_thread()

  • app (Optional[Any]) – Optionally provide a prexisting application to register to

  • server_type (Optional[idom.server.proto.ServerFactory[idom.server.prefab._App, idom.server.prefab._Config]]) –

Returns

The server instance and a function for adding views. See idom.widgets.multiview() for details.

Return type

Tuple[idom.widgets.MultiViewMount, idom.server.proto.Server[idom.server.prefab._App]]

idom.server.prefab.hotswap_server(server_type=None, host='127.0.0.1', port=None, server_config=None, run_kwargs=None, app=None, sync_views=False)[source]

Set up a server where views can be dynamically swapped out.

In other words this allows the user to work with IDOM in an imperative manner. Under the hood this uses the idom.widgets.hotswap() function to swap the views on the fly.

Parameters
  • server – The server type to start up as a daemon

  • host (str) – The server hostname

  • port (Optional[int]) – The server port number

  • server_config (Optional[idom.server.prefab._Config]) – Value passed to ServerFactory()

  • run_kwargs (Optional[Dict[str, Any]]) – Keyword args passed to run_in_thread()

  • app (Optional[Any]) – Optionally provide a prexisting application to register to

  • sync_views (bool) – Whether to update all displays with newly mounted components

  • server_type (Optional[idom.server.proto.ServerFactory[idom.server.prefab._App, idom.server.prefab._Config]]) –

Returns

The server instance and a function for swapping views. See idom.widgets.hotswap() for details.

Return type

Tuple[Callable[[Callable[[…], ComponentType]], None], idom.server.proto.Server[idom.server.prefab._App]]

Sanic Servers

class idom.server.sanic.Config(*args, **kwargs)[source]

Bases: dict

Config for SanicRenderServer

idom.server.sanic.PerClientStateServer(constructor, config=None, app=None)[source]

Return a SanicServer where each client has its own state.

Implements the ServerFactory protocol

Parameters
  • constructor (Callable[[...], ComponentType]) – A component constructor

  • config (Optional[idom.server.sanic.Config]) – Options for configuring server behavior

  • app (Optional[sanic.app.Sanic]) – An application instance (otherwise a default instance is created)

Return type

idom.server.sanic.SanicServer

idom.server.sanic.SharedClientStateServer(constructor, config=None, app=None)[source]

Return a SanicServer where each client shares state.

Implements the ServerFactory protocol

Parameters
  • constructor (Callable[[...], ComponentType]) – A component constructor

  • config (Optional[idom.server.sanic.Config]) – Options for configuring server behavior

  • app (Optional[sanic.app.Sanic]) – An application instance (otherwise a default instance is created)

Return type

idom.server.sanic.SanicServer

class idom.server.sanic.SanicServer(app)[source]

Bases: object

A thin wrapper for running a Sanic application

See idom.server.proto.Server for more info

Parameters

app (Sanic) –

Return type

None

Tornado Servers

class idom.server.tornado.Config(_typename, _fields=None, /, **kwargs)[source]

Bases: dict

Render server config for TornadoRenderServer subclasses

idom.server.tornado.PerClientStateServer(constructor, config=None, app=None)[source]

Return a TornadoServer where each client has its own state.

Implements the ServerFactory protocol

Parameters
Return type

idom.server.tornado.TornadoServer

class idom.server.tornado.TornadoServer(app)[source]

Bases: object

A thin wrapper for running a Tornado application

See idom.server.proto.Server for more info

Parameters

app (Application) –

Return type

None

class idom.server.tornado.PerClientStateModelStreamHandler(application, request, **kwargs)[source]

Bases: tornado.websocket.WebSocketHandler

A web-socket handler that serves up a new model stream to each new client

Parameters
Return type

None

async open(*args, **kwargs)[source]

Invoked when a new WebSocket is opened.

The arguments to open are extracted from the tornado.web.URLSpec regular expression, just like the arguments to tornado.web.RequestHandler.get.

open may be a coroutine. on_message will not be called until open has returned.

Changed in version 5.1: open may be a coroutine.

Parameters
  • args (str) –

  • kwargs (str) –

Return type

None

async on_message(message)[source]

Handle incoming messages on the WebSocket

This method must be overridden.

Changed in version 4.5: on_message can be a coroutine.

Parameters

message (Union[str, bytes]) –

Return type

None

on_close()[source]

Invoked when the WebSocket is closed.

If the connection was closed cleanly and a status code or reason phrase was supplied, these values will be available as the attributes self.close_code and self.close_reason.

Changed in version 4.0: Added close_code and close_reason attributes.

Return type

None

Test Tooling

idom.testing.find_available_port(host, port_min=8000, port_max=9000)[source]

Get a port that’s available for the given host and port range

Parameters
  • host (str) –

  • port_min (int) –

  • port_max (int) –

Return type

int

class idom.testing.ServerMountPoint(server_type=None, host='127.0.0.1', port=None, server_config=None, run_kwargs=None, mount_and_server_constructor=<function hotswap_server>, app=None, **other_options)[source]

Bases: Generic[idom.testing._Mount, idom.testing._Server]

A context manager for imperatively mounting views to a render server when testing

property log_records: List[logging.LogRecord]

A list of captured log records

url(path='', query=None)[source]

Return a URL string pointing to the host and point of the server

Parameters
  • path (str) – the path to a resource on the server

  • query (Optional[Any]) – a dictionary or list of query parameters

Return type

str

list_logged_exceptions(pattern='', types=<class 'Exception'>, log_level=40, del_log_records=True)[source]

Return a list of logged exception matching the given criteria

Parameters
  • log_level (int) – The level of log to check

  • exclude_exc_types – Any exception types to ignore

  • del_log_records (bool) – Whether to delete the log records for yielded exceptions

  • pattern (str) –

  • types (Union[Type[Any], Tuple[Type[Any], ...]]) –

Return type

List[BaseException]

General Utilities

class idom.utils.Ref(initial_value=<object object>)[source]

Bases: Generic[idom.utils._RefValue]

Hold a reference to a value

This is used in imperative code to mutate the state of this object in order to incur side effects. Generally refs should be avoided if possible, but sometimes they are required.

Notes

You can compare the contents for two Ref objects using the == operator.

current

The present value

set_current(new)[source]

Set the current value and return what is now the old value

This is nice to use in lambda functions.

Parameters

new (idom.utils._RefValue) –

Return type

idom.utils._RefValue

idom.utils.html_to_vdom(source, *transforms)[source]

Transform HTML into a DOM model

Parameters
  • source (str) – The raw HTML as a string

  • transforms (Callable[[Dict[str, Any]], Any]) – Functions of the form transform(old) -> new where old is a VDOM dictionary which will be replaced by new. For example, you could use a transform function to add highlighting to a <code/> block.

Return type

Dict[str, Any]

class idom.utils.HtmlParser(*, convert_charrefs=True)[source]

Bases: html.parser.HTMLParser

HTML to VDOM parser

Example

parser = HtmlParser()

parser.feed(an_html_string)
parser.feed(another_html_string)
...

vdom = parser.model()
model()[source]

Get the current state of parsed VDOM model

Return type

Dict[str, Any]

feed(data)[source]

Feed in HTML that will update the HtmlParser.model()

Parameters

data (str) –

Return type

None

reset()[source]

Reset the state of the parser

Return type

None

Web Modules

idom.web.module.NAME_SOURCE = 'NAME'

A named souce - usually a Javascript package name

idom.web.module.URL_SOURCE = 'URL'

A source loaded from a URL, usually a CDN

idom.web.module.module_from_url(url, fallback=None, resolve_exports=False, resolve_exports_depth=5, unmount_before_update=False)[source]

Load a WebModule from a URL_SOURCE

Parameters
  • url (str) – Where the javascript module will be loaded from which conforms to the interface for Custom Javascript Components

  • fallback (Optional[Any]) – What to temporarilly display while the module is being loaded.

  • resolve_imports – Whether to try and find all the named exports of this module.

  • resolve_exports_depth (int) – How deeply to search for those exports.

  • unmount_before_update (bool) – Cause the component to be unmounted before each update. This option should only be used if the imported package failes to re-render when props change. Using this option has negative performance consequences since all DOM elements must be changed on each render. See #461 for more info.

  • resolve_exports (bool) –

Return type

idom.web.module.WebModule

idom.web.module.module_from_template(template, package, cdn='https://esm.sh', fallback=None, resolve_exports=False, resolve_exports_depth=5, unmount_before_update=False)[source]

Create a WebModule from a framework template

This is useful for experimenting with component libraries that do not already support IDOM’s Custom Javascript Components interface.

Warning

This approach is not recommended for use in a production setting because the framework templates may use unpinned dependencies that could change without warning.cIt’s best to author a module adhering to the Custom Javascript Components interface instead.

Parameters
  • template (str) – The name of the framework template to use with the given package (only react is supported at the moment).

  • package (str) – The name of a package to load. May include a file extension (defaults to .js if not given)

  • cdn (str) – Where the package should be loaded from. The CDN must distribute ESM modules

  • fallback (Optional[Any]) – What to temporarilly display while the module is being loaded.

  • resolve_imports – Whether to try and find all the named exports of this module.

  • resolve_exports_depth (int) – How deeply to search for those exports.

  • unmount_before_update (bool) – Cause the component to be unmounted before each update. This option should only be used if the imported package failes to re-render when props change. Using this option has negative performance consequences since all DOM elements must be changed on each render. See #461 for more info.

  • resolve_exports (bool) –

Return type

idom.web.module.WebModule

idom.web.module.module_from_file(name, file, fallback=None, resolve_exports=False, resolve_exports_depth=5, symlink=False, unmount_before_update=False)[source]

Load a WebModule from a URL_SOURCE using a known framework

Parameters
  • template – The name of the template to use with the given package

  • package – The name of a package to load. May include a file extension (defaults to .js if not given)

  • cdn – Where the package should be loaded from. The CDN must distribute ESM modules

  • fallback (Optional[Any]) – What to temporarilly display while the module is being loaded.

  • resolve_imports – Whether to try and find all the named exports of this module.

  • resolve_exports_depth (int) – How deeply to search for those exports.

  • unmount_before_update (bool) – Cause the component to be unmounted before each update. This option should only be used if the imported package failes to re-render when props change. Using this option has negative performance consequences since all DOM elements must be changed on each render. See #461 for more info.

  • name (str) –

  • file (Union[str, pathlib.Path]) –

  • resolve_exports (bool) –

  • symlink (bool) –

Return type

idom.web.module.WebModule

class idom.web.module.WebModule(source: str, source_type: SourceType, default_fallback: Optional[Any], export_names: Optional[Set[str]], file: Optional[Path], unmount_before_update: bool)[source]

Bases: object

Parameters
  • source (str) –

  • source_type (SourceType) –

  • default_fallback (Optional[Any]) –

  • export_names (Optional[Set[str]]) –

  • file (Optional[pathlib.Path]) –

  • unmount_before_update (bool) –

Return type

None

idom.web.module.export(web_module: idom.web.module.WebModule, export_names: str, fallback: Optional[Any], allow_children: bool) idom.web.module._VdomDictConstructor[source]
idom.web.module.export(web_module: idom.web.module.WebModule, export_names: Union[List[str], Tuple[str]], fallback: Optional[Any], allow_children: bool) List[idom.web.module._VdomDictConstructor]

Return one or more VDOM constructors from a WebModule

Parameters
  • export_names – One or more names to export. If given as a string, a single component will be returned. If a list is given, then a list of components will be returned.

  • fallback – What to temporarilly display while the module is being loaded.

  • allow_children – Whether or not these components can have children.

Widgets

idom.widgets.image(format, value='', attributes=None)[source]

Utility for constructing an image from a string or bytes

The source value will automatically be encoded to base64

Parameters
  • format (str) –

  • value (Union[str, bytes]) –

  • attributes (Optional[Dict[str, Any]]) –

Return type

idom.core.proto.VdomDict

idom.widgets.Input(callback, type, value='', attributes=None, cast=None, ignore_empty=True)[source]

Utility for making an <input/> with a callback

Parameters
  • callback (Callable[[str], None]) –

  • type (str) –

  • value (str) –

  • attributes (Optional[Dict[str, Any]]) –

  • cast (Optional[Callable[[str], Any]]) –

  • ignore_empty (bool) –

Return type

idom.core.proto.VdomDict

idom.widgets.hotswap(update_on_change=False)[source]

Swap out components from a layout on the fly.

Since you can’t change the component functions used to create a layout in an imperative manner, you can use hotswap to do this so long as you set things up ahead of time.

Parameters

update_on_change (bool) – Whether or not all views of the layout should be udpated on a swap.

Return type

Tuple[Callable[[Callable[[…], ComponentType]], None], Callable[[…], ComponentType]]

Example

import idom

show, root = idom.hotswap()
PerClientStateServer(root).run_in_thread("localhost", 8765)

@idom.component
def DivOne(self):
    return {"tagName": "div", "children": [1]}

show(DivOne)

# displaying the output now will show DivOne

@idom.component
def DivTwo(self):
    return {"tagName": "div", "children": [2]}

show(DivTwo)

# displaying the output now will show DivTwo
idom.widgets.multiview()[source]

Dynamically add components to a layout on the fly

Since you can’t change the component functions used to create a layout in an imperative manner, you can use multiview to do this so long as you set things up ahead of time.

Examples

import idom

mount, multiview = idom.widgets.multiview()

@idom.component
def Hello():
    return idom.html.h1(["hello"])

# auto static view ID
mount.add("hello", Hello)
# use the view ID to create the associate component instance
hello_component_instance = multiview("hello")

@idom.component
def World():
    return idom.html.h1(["world"])

generated_view_id = mount.add(None, World)
world_component_instance = multiview(generated_view_id)

Displaying root with the parameter view_id=hello_world_view_id will show the message ‘hello world’. Usually though this is achieved by connecting to the socket serving up the VDOM with a query parameter for view ID. This allow many views to be added and then displayed dynamically in, for example, a Jupyter Notebook where one might want multiple active views which can all be interacted with at the same time.

See idom.server.prefab.multiview_server() for a reference usage.

Return type

Tuple[idom.widgets.MultiViewMount, Callable[[…], ComponentType]]

class idom.widgets.MultiViewMount(views)[source]

Bases: object

Mount point for multiview()

Parameters

views (Dict[str, ComponentConstructor]) –

add(view_id, constructor)[source]

Add a component constructor

Parameters
  • view_id (Optional[str]) – The view ID the constructor will be associated with. If None then a view ID will be automatically generated.

  • constructor (Callable[[...], ComponentType]) – The component constructor to be mounted. It must accept no arguments.

Returns

The view ID that was assocaited with the component - most useful for auto-generated view IDs

Return type

str

remove(view_id)[source]

Remove a mounted component constructor given its view ID

Parameters

view_id (str) –

Return type

None

Misc Modules

class idom.server.proto.ServerFactory(*args, **kwargs)[source]

Bases: Protocol[idom.server.proto._App, idom.server.proto._Config]

Setup a Server

class idom.server.proto.Server(*args, **kwargs)[source]

Bases: Protocol[idom.server.proto._App]

A thin wrapper around a web server that provides a common operational interface

app: idom.server.proto._App

The server’s underlying application

run(host, port)[source]

Start running the server

Parameters
  • host (str) –

  • port (int) –

Return type

None

run_in_thread(host, port)[source]

Run the server in a thread

Parameters
  • host (str) –

  • port (int) –

Return type

threading.Thread

wait_until_started(timeout=None)[source]

Block until the server is able to receive requests

Parameters

timeout (Optional[float]) –

Return type

None

stop(timeout=None)[source]

Stop the running server

Parameters

timeout (Optional[float]) –

Return type

None

idom.server.utils.find_builtin_server_type(type_name)[source]

Find first installed server implementation

Raises

RuntimeError

Parameters

type_name (str) –

Return type

idom.server.proto.ServerFactory[Any, Any]

idom.server.utils.find_available_port(host, port_min=8000, port_max=9000)[source]

Get a port that’s available for the given host and port range

Parameters
  • host (str) –

  • port_min (int) –

  • port_max (int) –

Return type

int