This docs on this page refers to a PREVIOUS VERSION. For the latest stable release, go to https://docs.bokeh.org/

Archived docs for versions <= 1.0.4 have had to be modified from their original published configuration, and may be missing some features (e.g. source listing)

All users are encourage to update to version 1.1 or later, as soon as they are able.

bokeh.core.property.override — Bokeh 1.0.2 documentation

Source code for bokeh.core.property.override

#-----------------------------------------------------------------------------
# Copyright (c) 2012 - 2018, Anaconda, Inc. All rights reserved.
#
# Powered by the Bokeh Development Team.
#
# The full license is in the file LICENSE.txt, distributed with this software.
#-----------------------------------------------------------------------------
''' Provide the ``Override`` class, for overriding base class property
attributes.

.. note::
    This class should normally be imported from ``bokeh.core.properties``
    instead of directly from this module.

'''

#-----------------------------------------------------------------------------
# Boilerplate
#-----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function, unicode_literals

import logging
log = logging.getLogger(__name__)

#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------

# Standard library imports

# External imports

# Bokeh imports

#-----------------------------------------------------------------------------
# Globals and constants
#-----------------------------------------------------------------------------

__all__ = (
    'Override',
)

#-----------------------------------------------------------------------------
# General API
#-----------------------------------------------------------------------------

[docs]class Override(object): ''' Override attributes of Bokeh property in derived Models. When subclassing a Bokeh Model, it may be desirable to change some of the attributes of the property itself, from those on the base class. This is accomplished using the ``Override`` class. Currently, ``Override`` can only be use to override the ``default`` value for the property. Keyword Args: default (obj) : a default value for this property on a subclass Example: Consider the following class definitions: .. code-block:: python from bokeh.model import Model from bokeh.properties import Int, Override class Parent(Model): foo = Int(default=10) class Child(Parent): foo = Override(default=20) The parent class has an integer property ``foo`` with default value 10. The child class uses the following code: .. code-block:: python foo = Override(default=20) to specify that the default value for the ``foo`` property should be 20 on instances of the child class: .. code-block:: python >>> p = Parent() >>> p.foo 10 >>> c = Child() >>> c.foo 20 ''' def __init__(self, **kwargs): if len(kwargs) == 0: raise ValueError("Override() doesn't override anything, needs keyword args") self.default_overridden = 'default' in kwargs if self.default_overridden: self.default = kwargs.pop('default') if len(kwargs) > 0: raise ValueError("Unknown keyword args to Override: %r" % (kwargs))
#----------------------------------------------------------------------------- # Dev API #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Private API #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Code #-----------------------------------------------------------------------------