orrery.models.GlobalModelRegistry#

class GlobalModelRegistry[source]#

Bases: ModelRegistry

A ModelRegistry where Models can be added with an additional identifying prefix, allowing multiple Models of the same name to be added. An example use might be an application which has multiple windows open, where each window has its own set of Models (which might be stored in a ModelRegistry). The prefix allows you to distinguish Models for different windows while still maintaining a single global list of Models

Methods

add_invalidated_observer

Add observer to listen to invalidated callback of the specified Model

add_model

Add a model to this registry with the specified name

add_observer

Add observer to listen to changed callback of the specified Model

get_model

Return the model in this registry with the specified name

model_names

Return a Model containing a list of current model names

models

Return dictionary of registered model names to models

register_all

Register models contained in another registry with this registry

remove_invalidated_observer

Remove previously added invalidated observer

remove_observer

Remove previously added value changed observer

add_invalidated_observer(name, callback, **kwargs)#

Add observer to listen to invalidated callback of the specified Model

add_model(name, model=None, prefix=None)[source]#

Add a model to this registry with the specified name

Parameters:
  • name – Name used to reference the model in the registry

  • prefix – Optional prefix which to be added to the model name

  • model – The Model to add. If a model is not specified, a new ValueModel will be created

Returns:

the Model that was added to the registry

add_observer(name, callback, prefix=None, **kwargs)[source]#

Add observer to listen to changed callback of the specified Model

get_model(name, prefix=None)[source]#

Return the model in this registry with the specified name

Return type:

Model

model_names()#

Return a Model containing a list of current model names

Return type:

Model

models()#

Return dictionary of registered model names to models

Return type:

dict[str, Model]

register_all(registry, prefix=None)[source]#

Register models contained in another registry with this registry

Parameters:
  • registry – Registry containing the source models

  • prefix – Optional prefix which will be added to each model name when they are added to this registry

remove_invalidated_observer(name, callback_id)#

Remove previously added invalidated observer

remove_observer(name, callback_id, prefix=None)[source]#

Remove previously added value changed observer