Provide a base class for objects that can have declarative, typed, serializable properties.
Note
These classes form part of the very low-level machinery that implements the Bokeh model and property system. It is unlikely that any of these classes or their methods will be applicable to any standard usage or to anyone who is not directly developing on Bokeh’s own infrastructure.
HasProps
Base class for all class types that have Bokeh properties.
__init__
apply_theme
Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).
property_values (dict) – theme values to use in place of defaults
None
dataspecs
Collect the names of all DataSpec properties on this class.
DataSpec
This method always traverses the class hierarchy and includes properties defined on any parent classes.
names of DataSpec properties
set[str]
dataspecs_with_props
Collect a dict mapping the names of all DataSpec properties on this class to the associated properties.
mapping of names and DataSpec properties
dict[str, DataSpec]
equals
Structural equality of models.
other (HasProps) – the other instance to compare to
True, if properties are structurally equal, otherwise False
lookup
Find the PropertyDescriptor for a Bokeh property on a class, given the property name.
PropertyDescriptor
name (str) – name of the property to search for
descriptor for property named name
name
properties
Collect the names of properties on this class.
This method optionally traverses the class hierarchy and includes properties defined on any parent classes.
with_bases (bool, optional) – Whether to include properties defined on parent classes in the results. (default: True)
property names
properties_containers
Collect the names of all container properties on this class.
names of container properties
properties_with_refs
Collect the names of all properties on this class that also have references.
names of properties that have references
properties_with_values
Collect a dict mapping property names to their values.
Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.
include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)
mapping from property names to their values
dict
query_properties_with_values
Query the properties values of HasProps instances with a predicate.
query (callable) – A callable that accepts property descriptors and returns True or False
include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)
mapping of property names and values for matching properties
set_from_json
Set a property value on this object from JSON.
name – (str) : name of the attribute to set
json – (JSON-value) : value to set to the attribute to
models (dict or None, optional) –
Mapping of model ids to models (default: None)
This is needed in cases where the attributes to update also have values that have references.
setter (ClientSession or ServerSession or None, optional) –
This is used to prevent “boomerang” updates to Bokeh apps.
In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.
themed_values
Get any theme-provided overrides.
Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.
dict or None
unapply_theme
Remove any themed values and restore defaults.
update
Updates the object’s properties from the given keyword arguments.
Examples
The following are equivalent:
from bokeh.models import Range1d r = Range1d # set properties individually: r.start = 10 r.end = 20 # update properties together: r.update(start=10, end=20)
update_from_json
Updates the object’s properties from a JSON attributes dictionary.
json_attributes – (JSON-dict) : attributes and values to update
MetaHasProps
Specialize the construction of HasProps classes.
This class is a metaclass for HasProps that is responsible for creating and adding the PropertyDescriptor instances that delegate validation and serialization to Property attributes.
Property
abstract
A decorator to mark abstract base classes derived from HasProps.
accumulate_dict_from_superclasses
Traverse the class hierarchy and accumulate the special dicts MetaHasProps stores on classes:
name (str) –
name of the special attribute to collect.
Typically meaningful values are: __dataspecs__, __overridden_defaults__
__dataspecs__
__overridden_defaults__
accumulate_from_superclasses
Traverse the class hierarchy and accumulate the special sets of names MetaHasProps stores on classes:
Typically meaningful values are: __container_props__, __properties__, __properties_with_refs__
__container_props__
__properties__
__properties_with_refs__