### Navigation

- index
- modules |
- previous |
- Reconfigure docs »

# reconfigure.items.bound

class `reconfigure.items.bound.``BoundCollection`(node, item_class, selector=<function <lambda> at 0x7fbe853e2c80>)

  Binds a list-like object to a set of nodes

  Parameters:

  - node – target node (its children will be bound)
  - item_class – `BoundData` class for items
  - selector – `lambda x: bool`, used to filter out a subset of nodes

  `append`(item)
  `insert`(index, item)
  `pop`(index)
  `rebuild`()

    Discards cached collection and rebuilds it from the nodes

  `remove`(item)
  `to_dict`()
  `to_json`()

class `reconfigure.items.bound.``BoundData`(node=None, **kwargs)

  Binds itself to a node.

  `bind_*` classmethods should be called on module-level, after subclass declaration.

  Parameters:

  - node – all bindings will be relative to this node
  - kwargs – if `node` is `None`, `template(**kwargs)` will be used to create node tree fragment

  classmethod `bind`(data_property, getter, setter)

    Creates an arbitrary named property in the class with given getter and setter. Not usually used directly.

    Parameters:

    - data_property – property name
    - getter – `lambda: object`, property getter
    - setter – `lambda value: None`, property setter

  classmethod `bind_attribute`(node_attribute, data_property, default=None, path=<function <lambda> at 0x7fbe853fce60>, getter=<function <lambda> at 0x7fbe853fced8>, setter=<function <lambda> at 0x7fbe853fcf50>)

    Binds the value of node object’s attribute to a property

    Parameters:

    - node_attribute – `Node`‘s attribute name
    - data_property – property name to be created
    - default – default value of the property (is `PropertyNode` doesn’t exist)
    - path – `lambda self.node: PropertyNode`, can be used to point binding to another Node instead of `self.node`.
    - getter – `lambda object: object`, used to transform value when getting
    - setter – `lambda object: object`, used to transform value when setting

  classmethod `bind_child`(data_property, path=<function <lambda> at 0x7fbe85388398>, item_class=None)

    Directly binds a child Node to a BoundData property

    Parameters:

    - data_property – property name to be created
    - path – `lambda self.node: PropertyNode`, can be used to point binding to another Node instead of `self.node`.
    - item_class – a `BoundData` subclass to be used for the property value

  classmethod `bind_collection`(data_property, path=<function <lambda> at 0x7fbe853880c8>, selector=<function <lambda> at 0x7fbe85388140>, item_class=None, collection_class=<class 'reconfigure.items.bound.BoundCollection'>, **kwargs)

    Binds the subset of node’s children to a collection property

    Parameters:

    - data_property – property name to be created
    - path – `lambda self.node: PropertyNode`, can be used to point binding to another Node instead of `self.node`.
    - selector – `lambda Node: bool`, can be used to filter out a subset of child nodes
    - item_class – a `BoundData` subclass to be used for collection items
    - collection_class – a `BoundCollection` subclass to be used for collection property itself

  classmethod `bind_name`(data_property, getter=<function <lambda> at 0x7fbe85388230>, setter=<function <lambda> at 0x7fbe853882a8>)

    Binds the value of node’s `name` attribute to a property

    Parameters:

    - data_property – property name to be created
    - getter – `lambda object: object`, used to transform value when getting
    - setter – `lambda object: object`, used to transform value when setting

  classmethod `bind_property`(node_property, data_property, default=None, default_remove=[], path=<function <lambda> at 0x7fbe853fcc80>, getter=<function <lambda> at 0x7fbe853fccf8>, setter=<function <lambda> at 0x7fbe853fcd70>)

    Binds the value of a child `reconfigure.node.PropertyNode` to a property

    Parameters:

    - node_property – `PropertyNode`‘s `name`
    - data_property – property name to be created
    - default – default value of the property (is `PropertyNode` doesn’t exist)
    - default_remove – if setting a value contained in default_remove, the target property is removed
    - path – `lambda self.node: PropertyNode`, can be used to point binding to another Node instead of `self.node`.
    - getter – `lambda object: object`, used to transform value when getting
    - setter – `lambda object: object`, used to transform value when setting

  `template`(**kwargs)

    Override to create empty objects.

    Returns: | a `reconfigure.nodes.Node` tree that will be used as a template for new BoundData instance

  `to_dict`()
  `to_json`()

class `reconfigure.items.bound.``BoundDictionary`(key=None, **kwargs)

  Binds a dict-like object to a set of nodes. Accepts same params as `BoundCollection` plus `key`

  Parameters: | key – `lambda value: object`, is used to get key for value in the collection

  `items`()
  `iteritems`()
  `pop`(key)
  `rebuild`()
  `rebuild_dict`()
  `setdefault`(k, v)
  `to_dict`()
  `update`(other)
  `values`()

### Navigation

- index
- modules |
- previous |
- Reconfigure docs »